6

嘿,将 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]
        )
4

3 回答 3

6

尝试改变

includes = []

includes = ["re"]

这对我有用

于 2011-05-26T19:12:20.240 回答
2

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

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

于 2011-04-18T00:26:15.380 回答
0

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

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")])
于 2014-07-03T11:51:37.123 回答