I cannot distribute a cx_freeze generated .exe to another machine, because it seems the exe contains references to absolute paths on the machine that generated the .exe. I also had to include vcruntime140.dll direktly, because "include_msvcr": True
didnt copy the file.
This question has been asked before in a similar form, but does not have an answer: cx_Freeze copies path
On starting the script, the following errors show up (cannot copy/paste from the window, so i share a picture). You can see the references to an absolute path C:\Program Files (x86)\Python....
that obviously is not present on another machine.
from os.path import dirname
from cx_Freeze import setup, Executable
from config import settings
import os.path
import sys
import glob
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
DEPENDENCY_DIR = os.path.join(os.getcwd(), 'dependencies')
os.environ['TCL_LIBRARY'] = os.path.join(DEPENDENCY_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(DEPENDENCY_DIR, 'tcl', 'tk8.6')
packages = ["sepa", "datev", "atexit", "shiboken2", "PySide2"]
includes = []
excludes = ["Pyside2.Qt5WebEngineCore.dll"]
includefiles = ['qt', 'settings', 'config', os.path.join(DEPENDENCY_DIR, 'DLLs', 'tk86t.dll'),
os.path.join(DEPENDENCY_DIR, 'DLLs', 'tcl86t.dll'), os.path.join(DEPENDENCY_DIR, 'DLLs', 'vcruntime140.dll')]
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": packages,
"excludes": excludes,
"includes": includes,
"include_files": includefiles,
"optimize": 2,
"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="sepa_converter",
version=settings.version,
description="Programm zum Konvertiern von SEPA Dateien zum importieren in Buchhaltungsprogramme",
options={"build_exe": build_exe_options},
executables=[Executable("export_gui.py", base=base)])
#Debug DLLs von Pyside2 löschen
tmp = glob.glob("build/*/Pyside2/*d.dll")
for i in tmp:
os.remove(i)
tmp = glob.glob("build/*/Pyside2/*/*/*d.dll")
for i in tmp:
os.remove(i)
filelist = ['Qt5WebEngineCore.dll', 'icudt54.dll', 'opengl32sw.dll', 'Qt5Designer.dll', 'd3dcompiler_47.dll', 'Qt5Quick.dll']
for f in filelist:
for i in glob.glob("build/*/Pyside2/%s" % f):
os.remove(i)
Downgrading to cx_freeze 5.1.1 resolved the issue for me.
Steps to make it work:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With