使用Cx_freeze将Python打包成MSI Exe时的错误信息

2 投票
1 回答
688 浏览
提问于 2025-04-18 17:40

大家好,

我刚刚完成了一个项目,想把它做成一个可分发的exe文件。

问题是每次我尝试用cx_freeze来构建exe时,启动这个EXE就会出现一个错误信息:

Traceback(most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py",line 27, in <module>
    exec(code,m.__dict__)
File"calculator.py",line 1, in <module>
file"c:\Python\64bit\3.4\lib\importlib\_bootsrap.py",line2214,in_fine_and_load

这个错误信息中最相关的部分是:
`AttributeError:'module'对象没有'fix_up_module'这个属性

我用来设置的脚本是这个。

from cx_Freeze import setup, Executable


includefiles = ['prices.dat','raftlogomain.gif'] # include any files here that you wish
includes = []
excludes = []
packages = []

exe = Executable(
   script = "calculator.py",
   initScript = None,
   base = 'Win32GUI',
   targetName = "Glass Calculator.exe",
   copyDependentFiles = True,
   compress = True,
   appendScriptToExe = True,
   appendScriptToLibrary = True,
   icon = None 
)

setup(

    name = "Glass Calculator",
    version = "0.1",
    description = 'Bespoke Calculations',
    author = "Lewis Tabone",
    author_email = "lewis@raftfurniture.co.uk",
    options = {"build_exe": {"excludes":excludes,"packages":packages,
      "include_files":includefiles}},
    executables = [exe]
)

这个脚本其实很简单明了。

这让我很沮丧,因为我无能为力,肯定有人知道答案!

非常感谢大家的帮助!

1 个回答

2

重新发布这个作为答案:这是一个已知的错误,是因为你使用的Python 3.4版本和cx_Freeze构建时用的修复版本不一样。

这个网站重新安装cx_Freeze。这个版本是用新的Python版本重新编译的,修复了这个错误。

撰写回答