PyQT5安装过程

2021-10-20 20:51:13|?次阅读|上传:wustguangh【已有?条评论】发表评论

关键词:QT|来源:唯设编程网

本文介绍在Window10操作系统,Python 3.7.3版本安装PyQT5的过程。

1. 在CMD窗口输入命令:

       pip3 PyQt5

     如果下载速度慢,也可以使用命令:

       pip3 PyQt5 -i https://pypi.tuna.tsinghua.edu.cn/simple PyQt5

2. 修改环境变量:

    用户的Path增加:

           C:UsersuserAppDataLocalProgramsPythonPython37Libsite-packagesPyQt5Qt5pluginsplatforms

           C:UsersuserAppDataLocalProgramsPythonPython37Libsite-packagesPyQt5Qt5plugins

     系统的Path增加:

            C:UsersuserAppDataLocalProgramsPythonPython37Libsite-packagesPyQt5Qt5pluginsplatforms

3. 增加用户环境变量:

      QT_PLUGIN_PATH:C:UsersuserAppDataLocalProgramsPythonPython37Libsite-packagesPyQt5Qt5plugins

4. 不修改环境变量,可能会出现如下错误:

this application failed to start because on qt platform plugin could beinitilaied reinstalling the application may fis this problem

5. 测试代码     

import sys
from PyQt5 import QtWidgets, QtCore, QtGui
 
app = QtWidgets.QApplication(sys.argv)
widgetHello = QtWidgets.QWidget()
widgetHello.resize(280, 150)
widgetHello.setWindowTitle("Demo2_1")

LabHello = QtWidgets.QLabel(widgetHello)
LabHello.setText("Hello World, PyQt5")
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
LabHello.setFont(font)
size = LabHello.sizeHint()
LabHello.setGeometry(70, 60, size.width(), size.height())

widgetHello.show()
sys.exit(app.exec_())
发表评论0条 】
网友评论(共?条评论)..
PyQT5安装过程