【问题标题】:Python cx_freeze build errorPython cx_freeze 构建错误
【发布时间】:2017-06-21 22:37:18
【问题描述】:

我最近想通过 cx_freeze 使我的 python 脚本可执行。我试过python 3.5和3.6一样的错误...

作为错误,我在 stratup.py 第 14 行和第 26 行 exec(code, m,dict) 在 console.py 中得到 module.run()(这两个脚本都属于 cx_freeze)。

如果有人将他们的工作 setup.py 和一些他们用来构建 exe 的代码没有错误,那就太好了(任何不值得的代码我不想窃取哈哈,我只想将它与我的代码进行比较)

任何人都知道如何修复它,或者我必须在我的 python 脚本中做一些额外的导入?

【问题讨论】:

    标签: python-3.x module runtime-error executable cx-freeze


    【解决方案1】:

    我的 setup.py 版本

    import sys
    from cx_Freeze import setup, Executable
    
    base = None
    if sys.platform == 'win32' : base = 'Win32GUI'
    
    opts = { 'include_files' : ['Pixel Skull.png'] , 'includes' : ['re'] }
    
    setup(
    name = 'Number generator' ,
    version = '1.0' ,
    description = 'Random number generator' ,
    author = 'Silentstorm' ,
    options = {'build_exe' : opts } ,
    executables = [ Executable( 'Number generator.py' , base = base ) ] )
    

    完成后,在命令提示符中输入以下行:

    python setup.py bdist_msi
    

    我知道你想要一个 exe,但这会生成一个 MSI,当你运行 MSI 时,会生成一个 exe 文件。 希望对你有效。另外,如果可能的话,我可以得到你的 setup.py 的副本吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-28
      • 2014-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-15
      相关资源
      最近更新 更多