您尚未登录。

楼主 #1 2020-02-19 10:41:16

pythinker
会员
注册时间: 2019-02-12
已发帖子: 215
积分: 215

python3.7 使用 pip 命令安装 PyQt5 软件包了, 也可以手动安装.

E:\>E:\Python37\python.exe -m pip uninstall PyQt5
Uninstalling PyQt5-5.10.1:
  Would remove:
    E:\python37\lib\site-packages\pyqt5-5.10.1.dist-info\*
    E:\python37\lib\site-packages\pyqt5\*
    E:\python37\scripts\pylupdate5.exe
    E:\python37\scripts\pyrcc5.exe
    E:\python37\scripts\pyuic5.exe
Proceed (y/n)? y
  Successfully uninstalled PyQt5-5.10.1

旧的 PyQt5 运行就出错, 所以先卸载:



然后安装新的:

E:>E:\Python37\python.exe -m pip install pyqt5
Collecting pyqt5
  Downloading https://files.pythonhosted.org/packages/46/83/7c27aec708a1eb12812a
0b985eb42eebfe3bb87e294cdca1c4af308d2fa9/PyQt5-5.14.1-5.14.1-cp35.cp36.cp37.cp38
-none-win_amd64.whl (53.1MB)
    3% |█                               | 1.7MB 9.3kB/s eta 1:32:11
Operation cancelled by user

发现安装速度太慢, 所以去下载一个手动安装:
http://pypi.doubanio.com/packages/46/83/7c27aec708a1eb12812a0b985eb42eebfe3bb87e294cdca1c4af308d2fa9/PyQt5-5.14.1-5.14.1-cp35.cp36.cp37.cp38-none-win_amd64.whl#md5=81d3c49eb109cf1293025fe01cf66739


一切OK:

E:>E:\Python37\python.exe -m pip install d:\downloads\PyQt5-5.1
4.1-5.14.1-cp35.cp36.cp37.cp38-none-win_amd64.whl
Processing d:\downloads\pyqt5-5.14.1-5.14.1-cp35.cp36.cp37.cp38-none-win_amd64.w
hl
Collecting PyQt5-sip<13,>=12.7 (from PyQt5==5.14.1)
  Downloading https://files.pythonhosted.org/packages/66/a6/3f1609f1a77445a088be
e7490229a4d430c9d0e1afd8ebd185fbc9c6aa57/PyQt5_sip-12.7.1-cp37-cp37m-win_amd64.w
hl (58kB)
    100% |████████████████████████████████| 61kB
 77kB/s
Installing collected packages: PyQt5-sip, PyQt5
Successfully installed PyQt5-5.14.1 PyQt5-sip-12.7.1

离线

楼主 #2 2020-02-19 10:43:40

pythinker
会员
注册时间: 2019-02-12
已发帖子: 215
积分: 215

Re: python3.7 使用 pip 命令安装 PyQt5 软件包了, 也可以手动安装.

#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
ZetCode PyQt5 tutorial 

In this example, we receive data from
a QInputDialog dialog. 

Aauthor: Jan Bodnar
Website: zetcode.com 
Last edited: August 2017
"""

from PyQt5.QtWidgets import (QWidget, QPushButton, QLineEdit, 
    QInputDialog, QApplication)
import sys

class Example(QWidget):
    
    def __init__(self):
        super().__init__()
        
        self.initUI()
        
        
    def initUI(self):      

        self.btn = QPushButton('Dialog', self)
        self.btn.move(20, 20)
        self.btn.clicked.connect(self.showDialog)
        
        self.le = QLineEdit(self)
        self.le.move(130, 22)
        
        self.setGeometry(300, 300, 290, 150)
        self.setWindowTitle('Input dialog')
        self.show()
        
        
    def showDialog(self):
        
        text, ok = QInputDialog.getText(self, 'Input Dialog', 
            'Enter your name:')
        
        if ok:
            self.le.setText(str(text))
        
        
if __name__ == '__main__':
    
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

2020-02-19_104300.gif

拷贝几行代码: http://zetcode.com/gui/pyqt5/dialogs/

运行: E:\Python37\python.exe d:\8899\x.py

参考: http://zetcode.com/gui/pyqt5/

试一试, 完全OK

离线

#3 2020-02-19 12:24:52

phpweb
会员
注册时间: 2020-02-05
已发帖子: 3
积分: 3

Re: python3.7 使用 pip 命令安装 PyQt5 软件包了, 也可以手动安装.

QQ截图20200219122238.png

可以跑, 谢谢楼主.

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn