简体   繁体   中英

Converting python file to .exe using pyinstaller gives: This application failed to start because no Qt platform plugin could be initialized

错误信息

I've created a program using PyQt5 for the user interface, when converting it to a.exe file with pyinstaller (using the line >pyinstaller --onefile -w --hidden-import=pkg_resources.py2_warn pitch_trainer.py ) I get an executable, however when I try to run it I get the error message shown. I've looked for similar problems, however I can only find examples where the issue is with QT designer (eg PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized ).

Update for the unlikely scenario that others are facing the same problem: I found two instances of the plugins folder on my device. One matched the one in the executable (contained qminimal.dll, qoffscreen.dll and qwindows.dll ) whereas the other was slightly different, containing just qminimal.dll and qwindows.dll . I deleted the plugins in my executable folder and replaced it with a copy of the plugins folder at C:\\Users\\\\AppData\\Roaming\\Python\\Python37\\site-packages\\pyqt5_tools\\Qt\\plugins This now works without issue, so I guess pyinstaller must have picked out the incorrect (or corrupted) files to build the executable with.

I confirme the solution of Joe Pickles. For my case, i have to replace all plugins in C:\Users\UserName\anaconda3\envs\pyqt5\Library\plugins by C:\Users\UserName\anaconda3\envs\pyqt5\Lib\site-packages\PySide2\plugins

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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