Cx_Freeze - 自动包含模块

时间:2013-11-20 13:12:29

标签: python python-3.x pyqt distutils cx-freeze

我应该在下面的代码中包含我在我的.py中使用过的模块os模块,还是自动完成?以及排除了什么?我在.py中使用了pyqt4是否有必要在此setup.py文件中添加其名称?

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}

# 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 = "my-app",
        version = "0.9.0",
        description = "Copyright 2013",
        options = {"build_exe": build_exe_options},
        executables = [Executable("my_module.py", base=base)])

1 个答案:

答案 0 :(得分:2)

正如评论所说,自动检测到依赖关系,但有时您需要手动微调它们。 os和tkinter只是作为示例,您可能不需要它们用于您的项目。通常,您可以检测到import ed的任何内容,但如果您以其他方式加载插件库,则无法找到它们,因此您需要指定它们。

尝试冻结它,看看是否因为缺少任何内容而失败,然后返回并将其添加到packages

相关问题