CX_Freeze Do not Set ICON - python

I am not able to compile with Cx_freeze, When I put the item "icon" nothing happens.
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
executables = [Executable(script ='RabbiGet.py',base=base, icon ='icone.ico')]
includefiles = ['icone.ico','Softplan.png','rabbit.png','saj.png','down.png']
setup(name='RabbiGet',
version='1.0',
description='RabbitMQ downs',
author = "Patric Guisolffi",
options = {'build_exe': {'include_files':includefiles,'packages': ["os","sys","ctypes","win32con"]}},
executables=executables
)'''

Try like this:
include_files = ['Softplan.png','rabbit.png','saj.png','down.png']
options = {
'build_exe': {
'include_msvcr': True,
'build_exe': 'name_exe',
'include_files': include_files,
}
}
setup(
name="RabbiGet",
version="1.0",
author = "Patric Guisolffi",
description='RabbitMQ downs',
executables=executables,
options=options,
)

Related

Add a second script in setup.py CX_freeze

I try to make an executable file of my python script by using CX_Freeze.
import sys
from cx_Freeze import setup, Executable
company_name = 'FF'
product_name = 'Kleurmeting aardappelvleeskleur'
bdist_msi_options ={"upgrade_code": '{48B079F4-B598-438D-A62A-8A233A3F8901}',
"add_to_path": False,
"initial_target_dir": r'[ProgramFilesFolder]\%s\%s' % (company_name, product_name),
}
build_exe_options = {"includes": ['cv2', 'glob', 'numpy', 'pathlib', 'skimage', 'pandas',
'colormath.color_objects', 'colormath.color_conversions', 'os',
'argparse', 'tkinter', 'PIL', 'tkinter', 'sys', 'datetime'],}
# base="Win32GUI" should be used only for Windows GUI app
base = None
if sys.platform == "win32":
base = "Win32GUI"
exe = Executable(script="Apptest.py",
base=base,
)
setup(
name = product_name,
version = "0.3",
description = "Kleurmeting aardappelrassen!",
executables=[exe],
options={
"bdist_msi" : bdist_msi_options,
"build_exe" : build_exe_options}
)
It works pretty fine, but the problem is in my script Apptest.py I make a reference to an other script named Innovatortest.py.
So, I want to make one .exe, with two scripts.
How can I add this script in the setup.py?
Thanks

cx freeze : AttributeError: 'list' object has no attribute 'items'

import sys, os
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
# "packages": ["os"] is used as example only
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
# base="Win32GUI" should be used only for Windows GUI app
base = None
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
include_files = [(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'), os.path.join('lib', 'tk86t.dll')), (os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'), os.path.join('lib', 'tcl86t.dll'))]
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "Snake",
version = "0.1",
description = "A Classic Snake Game with a few Modifications!",
options = {"build_exe": include_files},
executables = [Executable("main.py", base=base)]
That's the setup.py code I'm using cx freeze on. although when I try to run it using python setup.py build the error in the title of this post shows up. tell me if I need to provide more info and thank you in advance!
The build_exe parameter is expected to be a dictionary of parameter/value sets. You need to check the documentation.
https://cx-freeze.readthedocs.io/en/latest/setup_script.html
I suspect you intended:
...
options = {"build_exe": {"include_files": include_files}},

cxfreeze widget with tkinter xgboost not showing but no error

My program is working in anaconda spyder. however, after freezing it all widgets that use the tkinter module work except for the widget with xgboost and pandas. No error showed, the build worked but the button is not working and not showing the widget.
I've tried importing and including xgboost in my setup.py file but all other widgets with tkinter didn't work altogether. No error still though. have anyone experienced or solved this issue?
Here's the closest thing that worked. This is my setup.py, when the other widgets worked with tkinter but not the one with xgboost and pandas.
from cx_Freeze import setup, Executable
import sys
import os
includes = []
include_files = [r"C:/Users/USER/Anaconda3/DLLs/tcl86t.dll",
r"C:/Users/USER/Anaconda3/DLLs/tk86t.dll",
r"C:/Users/USER/SAMPLE/xgboost_USE.model",
r"C:/Users/USER/SAMPLE/P1.ico"]
os.environ['TCL_LIBRARY'] = "C:/Users/USER/Anaconda3/tcl/tcl8.6"
os.environ['TK_LIBRARY'] = "C:/Users/USER/Anaconda3/tcl/tk8.6"
base = 'Win32GUI' if sys.platform == 'win32' else None
setup(name=application_title, version='1.0', description='SAMPLE',
options={"build_exe": {"includes": includes, "include_files":
include_files}},executables=
[Executable(r'C:/Users/USER/SAMPLE/sample.py', base=base)])
Please help.
I dont have any experience with xgboost but I know when you cx freeze pandas you will need to explicitly include numpy. I'll share a setup file I have that has pandas (and some other things you can delete out like boto I assume)
import sys
import cx_Freeze
import os.path
import scipy
base = None
if sys.platform == 'win32':
base = "Win32GUI"
#This part may depend on where your installation is
#This part is essential to copy the tkinter DLL files over
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
os.environ['REQUESTS_CA_BUNDLE'] = r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore\vendored\requests\cacert.pem'
executables = [cx_Freeze.Executable("test.py", base=base)]
addtional_mods = ['numpy.core._methods', 'numpy.lib.format']
packages = ["idna", "numpy", "boto3", 'boto3.s3.transfer', 'boto3.s3.inject', 'multiprocessing', "xlwt", 'numpy.core._methods', 'pandas']
options = {
'build_exe': {
'include_files':[
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
os.path.dirname(scipy.__file__),
r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore\vendored\requests\cacert.pem',
r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore',
],
'includes': addtional_mods,
'packages':packages,
},
}
cx_Freeze.setup(
name = "Test",
options = options,
version = "1.0.0.0",
description = 'Test',
executables = executables
)

cx_freeze + selenium + python 3 : No module named 'httplib'

Im trying to buld my app with selenium, i have this setup.py:
import sys
from cx_Freeze import setup, Executable
path_drivers = ( "C:\Python34\Lib\site-packages\PyQt5\plugins\sqldrivers\qsqlmysql.dll", "sqldrivers\qsqlmysql.dll" )
includes = ["atexit","PyQt5.QtCore","PyQt5.QtGui", "PyQt5.QtWidgets","PyQt5.QtSql", "selenium"]
includefiles = [path_drivers]
excludes = [
'_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter'
]
packages = ["os"]
path = []
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"includes": includes,
"include_files": includefiles,
"excludes": excludes,
"packages": packages,
"path": path
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
exe = None
if sys.platform == "win32":
exe = Executable(
script="main.py",
initScript = None,
base=None,
targetName="zeus.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup(
name = "telll",
version = "0.1",
author = 'me',
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [exe]
)
The build finish with no problems, but when i run my application:
ImportError: No module named 'httplib'
My configuration:
Python 3.4.3 32bit.
PyQt5
Selenium 2.46.0
Thaks for the help
httplib either isn't in your directory path or hasn't been imported.
try adding either of these two scripts to your code:
import httplib
httplib = httplib(config_file="your directory path to httplib")

I am trying to compile a program using cx freeze but with a redistribution package can anyone fix line 13

import cx_Freeze
import sys
base = None
if sys.platform == "win32":
base = "Win32GUI"
build_exe_options = {
"include_msvcr": True #skip error msvcr100.dll missing
}
executables = [cx_Freeze.Executable("Clock.pyw",base=base,icon="Icon.ico")]
cx_Freeze.setup(
name= "Clock client",
options = {"build_exe": build_exe_options ,{"packages":["tkinter"],"include_files":["Icon.ico"]}},
version = "0",
description = "Clock program",
executables = executables
)
how is line 13 supposed to be formatted as when I try to compile this code I get the error invalid syntax with the curly bracket highlighted what am I missing?
options = {"build_exe": build_exe_options ,{"packages":["tkinter"],"include_files":["Icon.ico"]}},
This code is wrong, because you shouldn't put the "build_exe_options ," bit.
Corrected:
options = {"build_exe": {"packages":["tkinter"],"include_files":["Icon.ico"]}},

Categories