运行PyQt5的程序报错:This application failed to start because no Ot platform plugin could be initialized. Reinstalling the application may fix this problem.
在这里插入图片描述
重试了重新安装,

pip uninstall pyqt5
pip install pyqt5

没有解决。

关闭PyCharm,重新打开,也没有解决;

将Lib\site-packages\PyQt5\Qt5\plugins\platforms目录下的文件,从其他正常的环境中拷贝过来,也没有解决。
在这里插入图片描述
将Lib\site-packages\PyQt5\Qt5\plugins\platforms的路径、虚拟环境的路径添加到用户变量、系统环境变量、并重启PyCharm也没有解决;

最终解决方案:
创建一个新的用户变量:
变量名=QT_QPA_PLATFORM_PLUGIN_PATH,
变量值=Lib\site-packages\PyQt5\Qt5\plugins\platforms的完整路径

在这里插入图片描述
配置保存后,关闭PyCharm再重新打开,问题解决。

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐