How to disable cx_freeze to automatically detect all modules

cx_freeze build includes all the modules installed on my machine, so freezing the assembly becomes huge. How to disable autodetection? I just want to create a small PyQt application:

import sys from cx_Freeze import setup, Executable path = sys.path + ["app"] includes = ["app.core", "app.utils"] excludes = ["tcl"] build_exe_options = { "path": path, "icon": "resources\icons\clock.ico"} base = None if sys.platform == "win32": base = "Win32GUI" setup( name = "app", version = "1.1", description = "My Application", options = {"build_exe": build_exe_options}, executables = [Executable("app.py", base=base, targetName="app.exe", shortcutName="Application", shortcutDir="DesktopFolder")]) 

I also have my custom modules, each of which has a utils submodule, so cx_freeze is putting the wrong module.

How can I install a strict list of modules that I need?

+1
source share
1 answer

It was pretty simple. This application uses custom modules, so I added the application folder to the path:

 path = sys.path + ["app"] 

The trick is that the application uses the utils module, and I have another "utils" module in my path to the OS. Another "utils" module imports a lot of material, such as matplotlib, PIL, etc. So I solved the problem by changing this environment:

 path = ["app"] + sys.path 

So cx_freeze gets the right modules when it freezes the executable.

+1
source

Source: https://habr.com/ru/post/979072/


All Articles