【问题标题】:exe error with cx_freezecx_freeze 的 exe 错误
【发布时间】:2011-04-09 06:25:46
【问题描述】:

嘿,将 python 脚本编译为 exe 相对较新。我使用 cx_freeze 来编译我的脚本,一旦它构建,我运行 exe,它给了我这个错误。有很多谷歌,但不太确定。错误是:

无法导入回溯模块。 例外:没有名为 re 的模块 原始异常:没有名为 re 的模块

不太清楚如何解决这个问题。我读到可能存在名为 re 的模块之间的冲突?在蟒蛇?以及 cx_freeze 模块中名为 re 的模块?

我的设置文件如下所示:

from cx_Freeze import setup, Executable

includes = []
includefiles = ['remindersText.pkl']
eggsacutibull = Executable(
    script = "podlancer.py",
    initScript = None,
    base = 'Win32GUI',
    targetName = "podlancer.exe",
    compress = True,
    copyDependentFiles = True,
    appendScriptToExe = False,
    appendScriptToLibrary = False,
    icon = None
    )

setup(
        name = "Podlancer",
        version = "0.1",
        author = 'jono',
        description = "Podlancer UI script",
        options = {"build_exe": {"includes":includes, "include_files": includefiles}},
        executables = [eggsacutibull]
        )

【问题讨论】:

  • 这是 cx_Freeze 中的一个错误 - 它应该在下一个版本中修复,希望在下一周左右发布。

标签: python pyqt4 cx-freeze


【解决方案1】:

尝试改变

includes = []

includes = ["re"]

这对我有用

【讨论】:

  • 传奇。 =) 谢谢兄弟!想知道实际发生了什么哈哈。我在编译它时需要包含那个 re 模块,因为它出于水的原因......因此将它放入包含(有道理,有点内疚我没想到!)......有人知道 re 模块的用途吗?跨度>
【解决方案2】:

如果运行时工作目录不是可执行文件所在的目录,cx_freeze 会出错。

你是第一次导入吗?当您以不同的顺序执行它们时会发生什么?

【讨论】:

    【解决方案3】:

    re 放入includes 时遇到同样的问题对我不起作用。它在重建 .py 文件时产生了一个cx_Freeze.freezer.ConfigError

    import sys
    from cx_Freeze import setup, Executable
    
    build_exe_options = {'include_files': ['re']}
    
    setup(  name = "Foreground Window Montior",
            version = "0.1",
            description = "Query the foreground window.",
            options = {'build_exe': build_exe_options},
            executables = [Executable("actWin_Query.py")])
    

    如果我将re 放入packages 而不是include_files,则不会产生此编译错误。

    import sys
    from cx_Freeze import setup, Executable
    
    build_exe_options = {"packages": ["re"]}
    
    setup(  name = "Foreground Window Montior",
            version = "0.1",
            description = "Query the foreground window.",
            options = {'build_exe': build_exe_options},
            executables = [Executable("actWin_Query.py")])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 2019-05-12
      • 1970-01-01
      相关资源
      最近更新 更多