Am having problems using cx_freeze - python

First of all, the technical stuff:
Python : 3.3
cx_freeze : 4.3.2
I have looked through several setups, but accomplished nothing. So far I only get a very quickly closing Python Command Line, and sigh, no exe.
The setup.py:
from cx_Freeze import setup, Executable
executables = [
Executable("Swiss Rounds.py", appendScriptToExe=True, appendScriptToLibrary=False)
]
buildOptions = dict(
create_shared_zip = False)
setup(
name = "hello",
version = "0.1",
description = "the typical 'Hello, world!' script",
options = dict(build_exe = buildOptions),
executables = executables)
Thank you people!

It looks like you forgot the base for your executable, so cx freeze doesn't know how to make the exe. This is how I structure my setup.py file. This setup will put the exe in a different folder if it is 32 bit.
import os, sys, platform
from cx_Freeze import setup, Executable
targetDir = "./build/"
build_exe_options = {
"icon": "/assets/images/icon.ico",
"build_exe": "/build/",
"packages": [],
"includes": ["re", "os", "atexit"],
"include_files": ["/assets/"],
"excludes": ["tkinter", "ttk", "socket", "doctest", "pdb", "unittest", "difflib",
"_bz2", "_hashlib", "_lzma", "_socket"],
"optimize": True,
"compressed": True,
}
is32bit = platform.architecture()[0] == '32bit'
if is32bit:
targetDir = "./buildX86/"
build_exe_options["build_exe"] = targetDir
# end
base = None
if sys.platform == "win32":
base = "Win32GUI"
# end
setup( name = "MyProgram",
version = "0.1",
description = "My program example",
options = {"build_exe": build_exe_options},
executables = [ Executable("/myprogram.py",
targetName="MyProgram.exe",
targetDir=targetDir,
base=base) ]
)
Run:
python setup.py build

Related

python - cx_freeze - Error about external module transifex.api

This is my cx_freeze setup.py file, with all the modules that I need:
import sys
from cx_Freeze import setup, Executable
import os
os.environ['TCL_LIBRARY'] = "C:\\Users\Maicol\AppData\Local\Programs\Python\\Python36\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\Maicol\AppData\Local\Programs\Python\\Python36\\tcl\\tk8.6"
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os",
"numpy",
"tkinter",
"zipfile",
"subprocess",
"time",
"gettext",
"ctypes",
"locale",
"PIL.Image",
"PIL.ImageTk",
"webbrowser",
"feedparser",
"transifex.api",
"polib"],
"includes":["transifex.api.requests.packages.core.idnadata"],
'include_files':['LICENSE',
"changelog.txt",
"tcl86t.dll",
"sld_icon_beta.ico",
"tk86t.dll",
"images",
"icons",
"locale"],
"include_msvcr": True
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "School Life Diary",
version = "0.3",
author="maicol07",
description = "Diario scolastico sempre con te!",
options = {"build_exe": build_exe_options},
executables = [Executable("main.py",
base=base,
icon="sld_icon_beta.ico",
shortcutName="School Life Diary",
shortcutDir="DesktopFolder"),
Executable("settings.py"),
Executable("subjects.py"),
Executable("timetable.py")])
When I build exe and run the main .exe file I get this error:
If you need any other code, just ask me! (See also previous posts for some snippets)
Thanks
Solved by myself removing the includes list and adding "idna" in the packages list.
Code:
import sys
from cx_Freeze import setup, Executable
import os
os.environ['TCL_LIBRARY'] = "C:\\Users\Maicol\AppData\Local\Programs\Python\\Python36\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\Maicol\AppData\Local\Programs\Python\\Python36\\tcl\\tk8.6"
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os",
"numpy",
"tkinter",
"zipfile",
"subprocess",
"time",
"gettext",
"ctypes",
"locale",
"PIL.Image",
"PIL.ImageTk",
"webbrowser",
"feedparser",
"requests",
"idna",
"transifex.api",
"polib",
],
#"includes":["transifex.api.requests.packages.core.idnadata"],
'include_files':['LICENSE',
"changelog.txt",
"tcl86t.dll",
"sld_icon_beta.ico",
"tk86t.dll",
"images",
"icons",
"locale"],
"include_msvcr": True
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "School Life Diary",
version = "0.3",
author="maicol07",
description = "Diario scolastico sempre con te!",
options = {"build_exe": build_exe_options},
executables = [Executable("main.py",
base=base,
icon="sld_icon_beta.ico",
shortcutName="School Life Diary",
shortcutDir="DesktopFolder"),
Executable("note.py"),
Executable("settings.py"),
Executable("subjects.py"),
Executable("timetable.py")])

cx_Freeze MSI error

I have successfully compiled my python file to cx_Freeze, but when I click on the application I get the following error:
error image link
Here is my setup.py:
import sys
from cx_Freeze import setup, Executable
company_name = 'Vagif Programs'
product_name = 'BananaCell'
bdist_msi_options = {
'upgrade_code': '{66620F3A-DC3A-11E2-B341-002219E9B01E}',
'add_to_path': False,
'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % (company_name,
product_name),
}
build_exe_options = {
'includes': ['tkinter', 'tkinter.filedialog', 'openpyxl.utils'],
}
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
exe = Executable(script='comparing.py',
base=base,
icon='icon.ico',
shortcutName='BananaCell',
shortcutDir='DesktopFolder'
)
setup(name=product_name,
version='1.0.0',
description='blah',
executables=[exe],
options={
'bdist_msi': bdist_msi_options,
'build_exe': build_exe_options})
Can anyone help me? Any help would be appreciated.

Set an icon for a .exe file

I've made a .exe file of a game I made in Python, but I'm not sure how to make that exe file have an icon, because it looks dull and boring. I want to somehow make the icon be a picture of an asteroid let's say, because I made the game asteroids. I used cx_freeze to compile it.
Add it to the options in your setup.py file:
setup(
...
options={
"build_exe": {
"icon": "path/to/icon.ico"
}
}
)
This is easier to understand!
import cx_Freeze
import sys
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("example.pyw", base=base)]
cx_Freeze.setup(
name = "SeaofBTC-Client",
options = {"build_exe": {"packages":["tkinter",],"icon":"example.ico"}},
version = "0.01",
description = "Sea of BTC trading application",
executables = executables
)

how can reference from one Eclipse project to another when using cx_freeze

I have a problem
I have eclipse work space it's contain 4project each project reference from anther project. When I need to make an executable file using cx_Freeze, it can't import the other referenced project to it?
thanks
I tried this code:
base = None
from cx_Freeze import setup, Executable
if sys.platform == "win32":
base = "Win32GUI"
exe = Executable(
script="MyForm.py",
base="Win32GUI",packages=['QtCore', 'QtGui', 'QtSvg','tkinter','time','os','cls_MyForm','threading','sys','DAL','FS_Watch_Collection'],
compress=False, copyDependentFiles=False)
setup(
name = "First Version of File Watcher",
version = "1",
description = "File Watcher Program",
executables = [exe])
and this code:
from cx_Freeze import setup, Executable
#http://www.youtube.com/watch?v=XHcDHSWRCRQ
#http://www.python-forum.org/pythonforum/viewtopic.php?f=4&t=34501&hilit=cxfreeze
includefiles = ['README.txt', 'CHANGELOG.txt']
includes = []
excludes = ['tkinter']
packages = ['pk_LocalStore','QtCore', 'QtGui', 'QtSvg','time','os','threading','sys']
setup(
name = 'First Version of File Watcher',
version = '0.1',
description = 'File Watcher Program',
author = 'ITE CO',
author_email = 'info#from-masr.com',
options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [Executable('MyForm.py')]
)
but it's not working correctly

cx_Freeze missing modules error

I am new to Python and cx_Freeze. Please help me to get it working.
And run the command:
python setup.py build
It is giving me the following error.
Missing modules:
? System imported from serial.serialcli
? TERMIOS imported from serial.serialposix
? clr imported from serial.serialcli
? wx imported from wxversion
I am using the following setup.py file.
# Let's start with some default (for me) imports...
from cx_Freeze import setup, Executable
# Process the includes, excludes and packages first
includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
packages = []
path = []
GUI2Exe_Target_1 = Executable(
# what to build
script = "..\esp\main.py",
initScript = None,
base = 'Win32GUI',
targetDir = r"dist",
targetName = "acup_new.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup(
version = "0.1",
description = "No Description",
author = "No Author",
name = "cx_Freeze Sample File",
options = {"build_exe": {"includes": includes,
"excludes": excludes,
"packages": packages,
"path": path
}
},
executables = [GUI2Exe_Target_1]
)
Based on this question, it seems like you may need to add these modules to the includes[] list in your setup.py file.
I don't recall having to do this when using cx_Freeze, but I'll edit this answer once I can find more information.

Categories

Resources