How to Fix Numpy Dependencies Path on a Python 3.7.3 Script on Linux Frozen with Cx_Freeze 6.0B1

Create executable with python 3.7 PyQt5 and cx_Freeze but DLL Failed to load

You might be facing Issue #504 of the cx_Freeze repository. In that case, quoting a comment by marceloduarte there:

The workaround is to copy python3.dll to the directory where the executable was made. cx_Freeze copies python37.dll, but does not copy python3.dll. The vcruntime140.dll may also have to be copied when it no longer exists on the system.

First try to manually copy these DLLs (you find them in the directory of your python installation containing python.exe) to the directory of your executable. If that solves the problem, you can tell cx_Freeze to do it for you by using the include_files list of the build_exe_options. Modify you setup script as follows:

import os
python_dir = os.path.dirname(sys.executable) # directory of your python installation
build_exe_options = {"packages": ["os", "matplotlib"],
"includes": ["PyQt5", "atexit"],
"include_files": [os.path.join(python_dir, "python3.dll"), os.path.join(python_dir, "vcruntime140.dll")],
"excludes": ["tkinter"]}

Maybe you need to copy further DLLs, such as msvcp140.dll, or any other DLL present inside the site-packages/PyQt5 directory (including subdirectories) of your Python installation.

Compiling python project with Cx-Freeze

Use "python -m setup.py build" on cmd, that will build exe.

Example setup with extra folders:

from cx_Freeze import setup, Executable
import sys

version = "0.0.6"

build_options = {
"packages": [],
"excludes": [],
"build_exe": "X:\\builds\\",
"include_files": ["Sequence_Sample/", "icons/"],
}

base = "Win32GUI" if sys.platform == "win32" else None

executables = [Executable("MainUIController.py", base=base, targetName="pym")]

setup(
name="Python Image Macro Project",
version=version,
description="Image Based macro project.",
options={"build_exe": build_options},
executables=executables,
)

Python 3.8 and later has problem with cx_freeze 6.1 - not copying python dll.
cx_freeze 6.2 is strongly recommended if that's the case.

You'll have to clone cx_freeze and build it, then install it to use 6.2.



Related Topics



Leave a reply



Submit