【问题标题】:Exe from cx_Freeze Program is Missing Modulecx_Freeze 程序中的 Exe 缺少模块
【发布时间】:2017-07-03 12:01:02
【问题描述】:

我用 cx_Freeze(3.5.0 64 位)构建了一个程序,我的设置看起来像这样

from cx_Freeze import setup, Executable
    setup(name='TOOL11',
          version ='0.1',
          description='Easily find best float combination',
          executables = [Executable("TOOL11.py")])

但是当我运行 build 文件夹中的 tool11.exe 时,cmd 会非常快速地打开和关闭。我记录了这件事并逐帧播放以查看错误:https://i.gyazo.com/fe6ec4b8743e2348c48ee927ac8c1284.png 似乎错误是 google 模块未安装在构建文件夹中。看到这一点,我将 import google 添加到我的 TOOL11.py 并尝试再次构建。我尝试再次运行 exe,但我得到了同样的错误。

我能做些什么来解决这个问题吗?谢谢

【问题讨论】:

    标签: python python-3.5


    【解决方案1】:

    你没有说你是如何尝试添加导入谷歌的。 你试过吗?

    from cx_Freeze import setup, Executable
    setup(name='TOOL11',
          version ='0.1',
          description='Easily find best float combination',
          options={"build_exe": {"includes":["google"]}},
          executables = [Executable("TOOL11.py")])
    

    【讨论】:

    • 我尝试通过将import google 放入 TOOL11.py 文件来添加 google。我刚刚运行了 setup.py,它看起来像这样:from cx_Freeze import setup, Executable setup(name='TOOL11', version ='0.1', description='Easily find best float combination', options={"build_exe": {"includes":["google"]}}, executables = [Executable("TOOL11.py")]) 但得到了这个错误:pastebin.com/LTXCvi86
    • 其他解决方案:你可以下载这个文件:(github.com/google/protobuf/blob/master/python/google/protobuf/…),把它放到你的steam文件夹里,修改from google.protobuf.internal.python_message import GeneratedProtocolMessageType as _ProtoMessageType为from python_message import GeneratedProtocolMessageType as _ProtoMessageType
    • 我在 build\exe.win-amd64-3.5\steam\util 中看到了一个 init 文件,但它已经编译好了,看起来像这样:i.gyazo.com/ec19235655fcd0236af3a62d42d2b11f.png第 10 行也是空白的。这是你说的文件/文件夹吗?
    • 不,是c:\Python35\lib\site-packages\steam\util\__init__.py
    • 我尝试注释掉第 10 行,但没有奏效。下载 python_message.py 并将其放在 C:\Python35\Lib\site-packages\steam\util 中。尝试使用我之前的 setup.py 再次构建(不包括 include google 行),但仍然只是超级快速地打开和关闭了 cmd。我还应该使用 setup.py 中的描述行进行构建吗? python_message.py 应该在 steam 文件夹还是 util 文件夹中?谢谢编辑:尝试在刚刚使用的 Steam 文件夹中使用 python_messages,而不是在 util 下,但它仍然只是超级快速地打开和关闭
    猜你喜欢
    • 1970-01-01
    • 2011-12-25
    • 2019-03-11
    • 2017-05-26
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多