繁体   English   中英

Pyinstaller:无法执行脚本 pyi_rth_qt4plugins

[英]Pyinstaller: Failed to execute script pyi_rth_qt4plugins

当我运行由 pyinstaller 创建的 .exe 时,它​​有错误消息,如下面的屏幕截图所示。

我在运行 exe 时遇到的错误

我使用 Python 3.6.4、pyinstaller 3.4 和 PyQt5 5.12 在 Windows 10 中制作我的 GUI 程序。为什么运行 .exe 时 .exe 需要 PySide 模块和 PyQt4? 我不明白。 .py 可以在没有任何错误的情况下运行。

实际上,在我收到此错误之前,我遇到了错误Exception:Cannot find PyQt4 plugin directories在生成 exe 的过程中Exception:Cannot find PyQt4 plugin directories ,但我认为我不需要 PyQt4,所以我卸载了它。 然后 pyinstaller 过程继续进行,直到出现新错误。

Exception:
Cannot find existing PyQt5 plugin directories
Paths checked: C:/qt64/qt_1544645195969/_h_env/Library/plugins

我通过将 pyqt5qmlplugin.dll 复制到上面提到的路径C:/qt64/qt_1544645195969/_h_env/Library/plugins来解决它。 最后我得到了 .exe,但不幸的是我仍然得到一个错误,显示在屏幕截图中,我无法用 pip 安装 PyQt4。 它报告:

Could not find a version that satisfies the requirement PyQt4 (from versions: )  
No matching distribution found for PyQt4

我也无法安装 PySide,因为only these Python versions are supported: [(2.6), (2.7), (3.2), (3.3), (3.4)]

对我有用的是使用 Python 3.5 创建一个新环境并在其中安装脚本所需的所有库。 如果您使用的是 Anaconda,请按照以下步骤操作:

conda create yourenvironmentname python=3.5

conda 激活您的环境名称

将“yourenvironmentname”替换为您想要的环境名称。

如果不使用 Anaconda:

pipenv --python 3.5

如果它不起作用,请尝试使用 python 3.4。

问题在于安装程序正在识别 pyqt4。 要解决此问题,请执行以下操作:

  1. 转到“\\Lib\\site-packages\\PyInstaller\\loader\\rthooks\\pyi_rth_qt4plugins.py”。
  2. 注释掉一切。
  3. 完成后,重新运行pyinstaller

    它应该工作。 祝你好运。

如果您在程序中使用 PyQt5,请转到以下目录中的“ pyi_rth_qt4plugins.py ”文件: Local\\Continuum\\anaconda3\\Lib\\site-packages\\PyInstaller\\loader\\rthooks.

代替

  1. PySide.QtCorePySide2.QtCore
  2. PyQt4.QtCore import QCoreApplication通过PyQt5.QtCore import QCoreApplication

我试图通过评论文件来遵循上面的步骤,但直到我这样做才起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM