您尚未登录。

#1 2020-02-19 09:40:34

pythinker
会员
注册时间: 2019-02-12
累计积分: 214

python3.7 使用 pip 命令已经不能安装 PyQt4 软件包了, 记录下载文件手动安装过程.

E:\Python37>E:\Python37\python.exe -m pip install PyQt4
Collecting PyQt4
  Could not find a version that satisfies the requirement PyQt4 (from versions:)
No matching distribution found for PyQt4

显示PyQt4 不在服务器上了, 安装 PyQt5 是正常的。

离线

#2 2020-02-19 09:43:23

pythinker
会员
注册时间: 2019-02-12
累计积分: 214

Re: python3.7 使用 pip 命令已经不能安装 PyQt4 软件包了, 记录下载文件手动安装过程.

打开 https://www.lfd.uci.edu/~gohlke/pythonlibs/

找到

PyQt4 (discontinued): a set of bindings for the Qt4 application framework.
Requires write access to the site-packages\PyQt4 folder to create qt.conf.
PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl
PyQt4‑4.11.4‑cp37‑cp37m‑win32.whl
PyQt4‑4.11.4‑cp36‑cp36m‑win_amd64.whl
PyQt4‑4.11.4‑cp36‑cp36m‑win32.whl
PyQt4‑4.11.4‑cp35‑cp35m‑win_amd64.whl
PyQt4‑4.11.4‑cp35‑cp35m‑win32.whl
PyQt4‑4.11.4‑cp34‑cp34m‑win_amd64.whl
PyQt4‑4.11.4‑cp34‑cp34m‑win32.whl
PyQt4‑4.11.4‑cp27‑cp27m‑win_amd64.whl
PyQt4‑4.11.4‑cp27‑cp27m‑win32.whl

我下载的是第一个: https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/PyQt4-4.11.4-cp37-cp37m-win_amd64.whl


安装:

E:\Python37>E:\Python37\python.exe -m pip install D:\Downloads\PyQt4-4.11.4-cp37-cp37m-win_amd64.whl
Processing d:\downloads\pyqt4-4.11.4-cp37-cp37m-win_amd64.whl
Installing collected packages: PyQt4
Successfully installed PyQt4-4.11.4

离线

#3 2020-02-19 09:56:23

pythinker
会员
注册时间: 2019-02-12
累计积分: 214

Re: python3.7 使用 pip 命令已经不能安装 PyQt4 软件包了, 记录下载文件手动安装过程.

来一个测试程序:

import sys
from PyQt4 import QtCore, QtGui
                                                     
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    label = QtGui.QLabel("Hello World")
    label.show()
    sys.exit(app.exec_())

2020-02-19_095544.gif

离线

#4 2020-02-19 10:12:21

pythinker
会员
注册时间: 2019-02-12
累计积分: 214

Re: python3.7 使用 pip 命令已经不能安装 PyQt4 软件包了, 记录下载文件手动安装过程.

import sys
from PyQt4 import QtGui


def main():
    
    app = QtGui.QApplication(sys.argv)
	
    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')

    label = QtGui.QLabel("Hello World")
    w.addWidget(label)
    w.show()
    
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()

离线

#5 2020-02-19 10:22:10

pythinker
会员
注册时间: 2019-02-12
累计积分: 214

Re: python3.7 使用 pip 命令已经不能安装 PyQt4 软件包了, 记录下载文件手动安装过程.

import sys
from PyQt4 import QtGui


class Example(QtGui.QWidget):
    
    def __init__(self):
        super(Example, self).__init__()
        
        self.initUI()
        
    def initUI(self):
        
        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        
        self.setToolTip('This is a <b>QWidget</b> widget')
        
        btn = QtGui.QPushButton('Button', self)
        btn.setToolTip('This is a <b>QPushButton</b> widget')
        btn.resize(btn.sizeHint())
        btn.move(50, 50)       
        
        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Tooltips')    
        self.show()
        
def main():
    
    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()

2020-02-19_102100.gif

参考: http://zetcode.com/gui/pyqt4/firstprograms/

离线

页脚

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

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