【问题标题】:converting .py to .exe using Python 3.5/3.6?使用 Python 3.5/3.6 将 .py 转换为 .exe?
【发布时间】:2018-02-13 05:54:22
【问题描述】:

我在 Python 3.6 中使用 PyQt5 内置的 GUI 创建了一个应用程序。某些模块仅适用于 Python 3.5 和 3.6。 我设法使用 py2app 在 Mac 上打包它。我正在尝试在 Windows 上做同样的事情。我尝试使用this guide,但我仍然有问题。 据我了解,我有 3 个选项:

  1. py2exe
  2. pyinstaller
  3. cx_Freeze

1) py2exe

根据herepy2exe仍然无法用于python3.6,那我需要使用python3.5。

使用 3.5,我收到此错误并且编译停止:

error: [Errno 2] No such file or directory: 'C:\\Users\\carlo\\AppData\\Roaming\\Python\\Python35\\site-packages\\py2exe\\run-py3.5-win32.exe'

2) pyinstaller 通过 Python3.5 运行 pyinstaller: pyinstaller --onefile APP.py

我只收到一堆警告(未找到 lib),但编译已结束。但是,创建的 EXE 打开命令提示符并弹出以下错误:

   Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_qt5plugins.py", line 46, in <module>
  File "c:\program files (x86)\python35-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 573, in load_module
    module = loader.load_module(fullname)
ImportError: DLL load failed: %1 is not a valid Win32 application.
Failed to execute script pyi_rth_qt5plugins

3) cx_Freeze 使用python3.5,它首先给出'TCL_LIBRARY'错误。按照说明here 编译顺利进行。但是,创建的应用程序会立即打开和关闭。它根本行不通。 使用python3.6,编译好像没问题。当我尝试打开应用程序时,会弹出此错误。我只是设法快速接受screen-shot:

有人有什么建议吗?我没有考虑任何替代方案?

【问题讨论】:

    标签: python python-3.x pyinstaller py2exe cx-freeze


    【解决方案1】:

    我设法解决了这个问题! 我遵循了here 的指示。 我第一次运行(使用 Python3.5):

    pyinstaller CodeName.py

    然后我按照link 中的说明修改了 .spec 文件,神奇的事情发生了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 2020-11-06
      • 2022-06-18
      • 2017-08-19
      相关资源
      最近更新 更多