本文主要是介绍This application failed to start because no Qt platform plugin could be initialized,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【遇到问题】matplotlib画图生成EXE时,报错This application failed to start because no Qt platform plugin could be initialized
【首先】
VS CODE用matplotlib画图,遇到问题:
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "D:\ProgramFiles\Anaconda3\Lib\site-packages\PyQt5\plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.Available platform plugins are: direct2d, minimal, offscreen, windows.
【然后】
尝试增加环境变量,把文件夹到哪个地方等操作,无效。然后下载了Pycharm,编译,无问题。
打包成exe后,运行,还是报错,感觉根本问题没有解决:
尝试一:输入windeployqt.exe test.exe找到依赖库;失败!
https://www.jianshu.com/p/304c9e6de4d2
尝试二:
添加环境变量:失败
尝试三:
添加必要的dll—找到路径:C:\ANACONDA\Lib\site-packages\PyQt5\Qt\plugins(这是我的安装路径),在此文件夹下找到platforms文件夹,然后拷贝整个文件夹,将其放到与exe相同的路径下(我文件夹下没有platforms,从QT安装包里拷贝过来)(失败)
https://blog.csdn.net/lynjan/article/details/81557215
尝试四:(成功!)
在代码里添加路径
https://blog.csdn.net/zzx188891020/article/details/105813976
终于是搞好了
查看生成的EXE,旁边自己添加了dll的文件夹。推测,的确是没有找到这个dll,但是手动加进去又没用。PS:中间我有重装过一次pip install PyQt5 -i https://pypi.douban.com/simple
这篇关于This application failed to start because no Qt platform plugin could be initialized的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!