我按照以下说明为python2.7安装PyQt5。
我的系统是Mac OS Al Captain。使用Qt5.5库,PyQt5_gpl-5.7,sip-4.18.1库。
git commit
但是,它会产生如下错误,并拒绝启动应用程序代码,如下所示:
mkdir pyqt
cd pyqt/
virtualenv qtenv
source qtenv/bin/activate
mkdir tmp
cp /Users/ge/Downloads/PyQt-gpl-5.4.1.tar.gz ./tmp
cp /Users/ge/Downloads/sip-4.16.7.tar.gz ./tmp
cd tmp/
tar xvf sip-4.16.7.tar.gz
tar xvf PyQt-gpl-5.4.1.tar.gz
cd sip-4.16.7
python configure.py -d /Users/ge/pyqt/qtenv/lib/python2.7/site-packages --arch x86_64
make
sudo make install
sudo make clean
cd ../PyQt-gpl-5.4.1
python configure.py --destdir /Users/ge/pyqt/qtenv/lib/python2.7/site-packages --qmake /Applications/Qt/5.4/clang_64/bin/qmake
make
sudo make install
sudo make clean
产生的错误是:
from PyQt5 import QtGui # (the example applies equally well to PySide)
import pyqtgraph as pg
## Always start by initializing Qt (only once per application)
app = QtGui.QApplication([])
## Define a top-level widget to hold everything
w = QtGui.QWidget()
## Create some widgets to be placed inside
btn = QtGui.QPushButton('press me')
text = QtGui.QLineEdit('enter text')
listw = QtGui.QListWidget()
plot = pg.PlotWidget()
## Create a grid layout to manage the widgets size and position
layout = QtGui.QGridLayout()
w.setLayout(layout)
## Add widgets to the layout in their proper positions
layout.addWidget(btn, 0, 0) # button goes in upper-left
layout.addWidget(text, 1, 0) # text edit goes in middle-left
layout.addWidget(listw, 2, 0) # list widget goes in bottom-left
layout.addWidget(plot, 0, 1, 3, 1) # plot goes on right side, spanning 3 rows
## Display the widget as a new window
w.show()
## Start the Qt event loop
app.exec_()
然后我用谷歌搜索,一个临时解决方案是添加一个env路径到系统名为:
This application failed to start because it could not find or load the Qt platform plugin “cocoa”
我想知道在安装pyqt5时是否有任何方法可以设置它,而不是在安装后将此路径设置为我的系统。它应该是一些configure.py选项,对吗?