如何禁用cx_freeze自动检测所有模块 [英] How to disable cx_freeze to autodetect all modules

查看:120
本文介绍了如何禁用cx_freeze自动检测所有模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cx_freeze构建包含我的计算机上安装的所有模块,因此冻结的构建变得非常庞大。如何禁用自动检测功能?我只想构建一个小的PyQt应用程序:

cx_freeze build includes all modules, that installed on my machine, so freezed build becomes a huge. How to disable autodetection feature? I just want to build 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")])

我也有我的自定义模块,每个模块都有一个utils子模块,因此cx_freeze放置了错误的模块。

Also I have the my custom modules, each has a utils submodule, so cx_freeze put wrong module.

如何设置我需要的严格模块列表?

How can I set strict list of modules, which i need?

推荐答案

这很简单。
此应用程序使用自定义模块,因此我已将应用程序文件夹添加到路径:

It was quite simple. This application uses a custom modules, so I've added application folder to the path:

path = sys.path + ["app"]

诀窍在于应用程序使用模块 utils,而我还有其他我的操作系统路径中的 utils模块。其他 utils模块导入了很多东西,例如matplotlib,PIL等。
因此,我已经通过更改路径环境来解决问题,例如:

The trick is that app uses module "utils" and I have other "utils" module in my OS path. Other "utils" module imports a lot of stuff like matplotlib, PIL, etc. So I've solved problem by changing path environment like this:

path = ["app"] + sys.path

冻结可执行文件时,cx_freeze会获取正确的模块。

So, cx_freeze gets right modules when freeze executable.

这篇关于如何禁用cx_freeze自动检测所有模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆