pyqt5打包成exe 及 ...because it could not find or load the Qt platform plugin "windows"...问题解决

打包

安装pyinstaller

pip install pyinstaller

命令行执行如下命令,main.py为应用主程序,-F输出为单文件,-w 表示去掉控制台窗口。

pyinstaller -F -w  main.py

plugin “windows”问题

pyqt打包完成后,运行出错:

This application failed to start because it could not find or load the Qt platform plugin “windows”…

这里写图片描述

解决方法:拷贝pyqt的platforms文件夹到生成的可执行程序同级目录下,如我的是:D:\Anaconda3\pkgs\qt-5.9.6-vc14h62aca36_0\Library\plugins\platforms
注意qt版本的对应,一般为pkgs文件夹中的最新qt。

效果

这里写图片描述

猜你喜欢

转载自blog.csdn.net/nima1994/article/details/81106902