pycharm安装wxpython出错_PyCharm+PyQt5 : 主讲解决安装PyQt5 打开designer等时报错问题

主讲解决安装PyQt5 打开designer等时报错问题, 其他的参考都说的很明白了

.1. PyQt5安装

pip install pyqt5 -i https://pypi.tuna.tsinghua.edu.cn/simple

Qt for Python支持

2. PyQt5-tools

主要就是designer等工具

pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple

3 出现问题

32位Python的xxxx\Python38-32\Lib\site-packages\pyqt5_tools\Qt\bin的目录

16639861059bc378dd8e11799fb3cb5a.png

64位Python的xxxx\Python38-32\Lib\site-packages\pyqt5_tools\Qt\bin的目录

073eb75ea97212e75698b08020a876cd.png

出问题是在64bit

bb15e42e9b4e753a3c802c5efea7b877.png

解决方法: 将xxx\Python38\Lib\site-packages\pyqt5_tools\Qt 目录下的 plugins 合并进 xxx\Python38\Lib\site-packages\pyqt5_tools\Qt\bin目录下即可

Note: 安装之后的 designer等Qt工具都在 xxx\Python38\Lib\site-packages\pyqt5_tools\Qt\bin 目录下

4. Pycharm设置外部工具

在PyCharm里打开Settings → Tools → External Tools添加如下:

Name:QtDesigner

Program:C:\Python36\Lib\site-packages\pyqt5-tools\designer.exe

Working directory:$FileDir$

Name:PyUIC

Program:C:\Python36\python3.exe

Arguments:-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py

Working directory:$FileDir$

Name:PyInstaller

Program:C:\Python36\Scripts\pyinstaller.exe

Arguments:--paths C:\Python36\Lib\site-packages\PyQt5\Qt\bin -F -w $FileNameWithoutExtension$.py

Working directory:$FileDir$

5 实例

login.ui -> login.py

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'login.ui'

#

# Created by: PyQt5 UI code generator 5.14.2

#

# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Form(object):

def setupUi(self, Form):

Form.setObjectName("Form")

Form.resize(400, 115)

self.gridLayout = QtWidgets.QGridLayout(Form)

self.gridLayout.setObjectName("gridLayout")

self.checkBox = QtWidgets.QCheckBox(Form)

self.checkBox.setObjectName("checkBox")

self.gridLayout.addWidget(self.checkBox, 3, 0, 1, 3)

self.widget = QtWidgets.QWidget(Form)

self.widget.setObjectName("widget")

self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)

self.horizontalLayout.setContentsMargins(0, 0, 0, 0)

self.horizontalLayout.setSpacing(0)

self.horizontalLayout.setObjectName("horizontalLayout")

self.pushButton = QtWidgets.QPushButton(self.widget)

self.pushButton.setObjectName("pushButton")

self.horizontalLayout.addWidget(self.pushButton)

self.pushButton_2 = QtWidgets.QPushButton(self.widget)

self.pushButton_2.setObjectName("pushButton_2")

self.horizontalLayout.addWidget(self.pushButton_2)

self.gridLayout.addWidget(self.widget, 4, 0, 1, 3)

self.label = QtWidgets.QLabel(Form)

self.label.setObjectName("label")

self.gridLayout.addWidget(self.label, 0, 0, 1, 2)

self.label_2 = QtWidgets.QLabel(Form)

self.label_2.setObjectName("label_2")

self.gridLayout.addWidget(self.label_2, 2, 0, 1, 2)

self.lineEdit_2 = QtWidgets.QLineEdit(Form)

self.lineEdit_2.setObjectName("lineEdit_2")

self.gridLayout.addWidget(self.lineEdit_2, 2, 2, 1, 1)

self.lineEdit = QtWidgets.QLineEdit(Form)

self.lineEdit.setObjectName("lineEdit")

self.gridLayout.addWidget(self.lineEdit, 0, 2, 1, 1)

self.retranslateUi(Form)

QtCore.QMetaObject.connectSlotsByName(Form)

def retranslateUi(self, Form):

_translate = QtCore.QCoreApplication.translate

Form.setWindowTitle(_translate("Form", "Form"))

self.checkBox.setText(_translate("Form", "记住密码"))

self.pushButton.setText(_translate("Form", "取消"))

self.pushButton_2.setText(_translate("Form", "确定"))

self.label.setText(_translate("Form", "用户名"))

self.label_2.setText(_translate("Form", "密码"))

main.py 调用

import sys

from PyQt5 import QtWidgets

from login import Ui_Form

if __name__=="__main__":

app = QtWidgets.QApplication(sys.argv)

widget = QtWidgets.QWidget()

ui = Ui_Form()

ui.setupUi(widget)

widget.show()

sys.exit(app.exec_())

结果

addf564225a2779ca99ba1a4d6767d99.png

参考:

原文链接:https://blog.csdn.net/halo_hsuh/article/details/106128954

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值