【问题标题】:Converting python file to .exe using pyinstaller gives: This application failed to start because no Qt platform plugin could be initialized使用 pyinstaller 将 python 文件转换为 .exe 给出: This application failed to start because no Qt platform plugin could be initialized
【发布时间】:2020-09-04 03:42:48
【问题描述】:

我已经为用户界面创建了一个使用 PyQt5 的程序,当使用 pyinstaller 将其转换为 .exe 文件时(使用行 >pyinstaller --onefile -w --hidden-import=pkg_resources.py2_warn pitch_trainer.py)我得到了一个可执行文件,但是当我尝试运行它时出现错误显示的消息。我一直在寻找类似的问题,但是我只能找到问题出在 QT 设计器的示例(例如 PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized)。

【问题讨论】:

  • 移除--onefile选项
  • 我现在试试并提供更新
  • 我仍然收到同样的错误信息
  • 1) 从 CMD 运行命令:QT_DEBUG_PLUGINS=1 your.exe,2) 可执行文件旁边有哪些文件? 3)使用dependency walker查看是否缺少dll
  • 我得到 'QT_DEBUG_PLUGINS' is not recognized as an internal or external command, operable program or batch file. 如果有帮助,在文件路径 C:...\pitch_trainer\PyQt5\Qt\plugins\platforms 中包含我的 exe 的文件夹中,我有文件 qminimal.dll, qoffscreen.dll 和 qwindows.dll

标签: python qt pyqt5 pyinstaller


【解决方案1】:

针对其他人面临相同问题的不太可能的情况进行更新:我在我的设备上发现了插件文件夹的两个实例。一个匹配可执行文件中的那个(包含qminimal.dll, qoffscreen.dll and qwindows.dll),而另一个略有不同,仅包含qminimal.dll and qwindows.dll。我删除了可执行文件夹中的插件,并将其替换为 C:\Users\\AppData\Roaming\Python\Python37\site-packages\pyqt5_tools\Qt\plugins 的插件文件夹副本 这现在可以正常工作了,所以我猜 pyinstaller 一定选择了不正确(或损坏)的文件来构建可执行文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-06
    • 2020-12-05
    • 2016-08-03
    • 1970-01-01
    • 2021-12-28
    • 2019-02-01
    • 2023-01-18
    • 1970-01-01
    相关资源
    最近更新 更多