【发布时间】:2018-02-13 05:54:22
【问题描述】:
我在 Python 3.6 中使用 PyQt5 内置的 GUI 创建了一个应用程序。某些模块仅适用于 Python 3.5 和 3.6。 我设法使用 py2app 在 Mac 上打包它。我正在尝试在 Windows 上做同样的事情。我尝试使用this guide,但我仍然有问题。 据我了解,我有 3 个选项:
- py2exe
- pyinstaller
- 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