解决This application failed to start because no Qt platform plugin could be initialized问题

解决This application failed to start because no Qt platform plugin could be initialized问题

先贴测试代码:

from PyQt5.QtWidgets import QWidget, QApplication

if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = QWidget()
    w.show()
    w.setWindowTitle("Hello PyQt5")
    sys.exit(app.exec_())

 

添加系统环境变量:QT_QPA_PLATFORM_PLUGIN_PATH

路径:D:\软件\python\Lib\site-packages\PyQt5\Qt5\plugins

(即是python安装的位置)

网上也有Qt\plugins的,但是可能是因为版本原因,我的Qt下没有这个文件夹

添加后重启PyCharm即可!!!!!!!!!!!!!!!!!!!

 

posted @ 2021-06-05 17:22  淇实是我  阅读(2470)  评论(0编辑  收藏  举报