【问题标题】:Cx_Freeze - Include Modules automaticallyCx_Freeze - 自动包含模块
【发布时间】:2013-11-20 13:12:29
【问题描述】:

我应该在下面的代码中包含我在 .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)])

【问题讨论】:

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


    【解决方案1】:

    正如评论所说,依赖项是自动检测的,但有时您需要手动微调它们。 os 和 tkinter 只是作为示例,您的项目可能不需要它们。一般来说,你imported 的任何东西都可以被检测到,但是如果你以其他方式加载插件库,它就找不到它们,所以你需要指定它们。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多