exe错误与cx_freeze

时间:2011-04-09 06:25:46

标签: python pyqt4 cx-freeze

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

Cannot import traceback module.
Exception: No module named re
Original Exception: No module named re

不太确定如何解决这个问题。我读到可能在名为re的模块之间存在冲突?在python?和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]
        )

3 个答案:

答案 0 :(得分:6)

尝试更改

includes = []

includes = ["re"]

这对我有用

答案 1 :(得分:2)

如果运行时工作目录不是可执行文件所在的目录,则cx_freeze将进行barf。

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

答案 2 :(得分:0)

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")])