1. 程式人生 > >CentOS7.1下python2.7.10安裝PyQt4

CentOS7.1下python2.7.10安裝PyQt4

新人肯定跟我一樣,那就是plt.show()在Linux環境下不顯示,後來才明白,這是matplotlib依賴圖形環境,有興趣的可以去了解下matplotlib後端(Backend )相關知識.下面安裝PyQt4解決.
1.安裝sip
[[email protected] ~]# wget http://downloads.sourceforge.net/project/pyqt/sip/sip-4.17/sip-4.17.tar.gz
[[email protected] ~]# tar xvf sip-4.17.tar.gz
[[email protected]
~]# cd sip-4.17
[[email protected] sip-4.17]# python configure.py
[[email protected] sip-4.17]#  make & make install & make clean

2.通過安裝qscintilla安裝qt
[[email protected] ~]#yum -y install epel-release
[[email protected] ~]#yum install qscintilla*


3.安裝pyqt4
[
[email protected]
~]# wget http://downloads.sourceforge.net/project/pyqt/PyQt4/PyQt-4.11.4/PyQt-x11-gpl-4.11.4.tar.gz
[[email protected] ~]# tar xvf PyQt-x11-gpl-4.11.4.tar.gz
[[email protected] ~]# cd PyQt-x11-gpl-4.11.4
[[email protected] PyQt-x11-gpl-4.11.4]# python configure.py -q  /usr/lib64/qt4/bin/qmake
[
[email protected]
PyQt-x11-gpl-4.11.4]# make & make install & make clean

4.測試
[[email protected] PyQt-x11-gpl-4.11.4]# python
Python 2.7.10 (default, Dec  7 2015, 15:42:49) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> import matplotlib
>>> matplotlib.use('qt4agg')
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
>>> plt.show()
>>> exit()