安装PyQt5并解决This application failed to start because it could not find or load the Qt platform plugin"

安装PyQt5

1、使用命令:pip install python-qt5
2、安装完成后可以在%python%\Lib\site-packages\PyQt5目录下找到designer.exe文件,即可正常编辑

注意

如果启动后弹出This application failed to start because it could not find or load the Qt platform plugin "windows"错误,可以进入plugins目录,将platforms目录粘贴至与desinger.exe文件同级即可解决。
安装PyQt5并解决This application failed to start because it could not find or load the Qt platform plugin

使用

1、 打开File—>Settings—>External Tools,点击加号来添加自己的工具
Name:QtDesigner
Group:Qt
Programs:C:\My\python\Lib\site-packages\PyQt5\designer.exe(这里是各位自己的designer路径,之前所看到的)
Working directory:$ProjectFileDir$
安装PyQt5并解决This application failed to start because it could not find or load the Qt platform plugin
2、 打开File—>Settings—>External Tools,点击加号来添加自己的工具
Name:Pyuic
Group:Qt
Program:C:\My\python\python.exe(各位自己的python路径)
Arguments:-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
Working directory:$FileDir$
安装PyQt5并解决This application failed to start because it could not find or load the Qt platform plugin
3、把制作好的ui文件打开后,选择pyuic即可转换为*.py文件
安装PyQt5并解决This application failed to start because it could not find or load the Qt platform plugin
4、调用方式

from PyQt5 import QtCore, QtGui, QtWidgets
import sys
if __name__ == "__main__":
        import sys
        app=QtWidgets.QApplication(sys.argv)
        widget=QtWidgets.QMainWindow()
        ui=Ui_MainWindow()
        ui.setupUi(widget)
        widget.show()
        sys.exit(app.exec_())

你可能感兴趣的:(笔记)