Ubuntu14配置安裝PyQt4,PyQt5

1.PyQt4安裝

PyQt4 推薦用APT-GET安裝 python


sudo apt-get install libxext6 libxext-dev libqt4-dev libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig "python-qt4-*" python-qt4
很簡單,主要記錄下在python3環境下pyqt5


2.PyQt5安裝

2.1.python sip install

先去下載了sip sql

tar -xvf sip*.tar.gz 
python configure.py 
make  
sudo make install

2.2 安裝Qt5

這裏有source下載,http://www.riverbankcomputing.co.uk/software/pyqt/download5 shell

也有run文件下載,http://qt-project.org/downloads bash

source仍是./configure && make &&sudo make install,若是是run的記得要先加x權限 app

sudo chmod +x **.run ui

安裝完後把路徑加到環境變量~/.bash_profile,個人是 spa

export PATH=$PATH:/opt/Qt5.3.1/5.3/gcc_64/bin
sudo ln -s /opt/Qt5.3.1/5.3/gcc_64/bin/qmake /usr/local/bin



2.3 pyqt5 install

安裝pyqt5須要上面的sip,還須要qmake,因此上面須要先裝Qt5 code

將下面的qmake替換成你的目錄,以及site-packages/也就是包的位置,接着編譯 ip

$sudo python3 configure.py --qmake /opt/Qt5.3.1/5.3/gcc_64/bin/qmake 

安裝 get

sudo make && sudo make install

一個簡單的示例以下:

import sys from PyQt5  import QtCore, QtGui, QtWidgets if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    w = QtWidgets.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    sys.exit(app.exec_())

若是過程當中有編譯報錯能夠試着

sudo ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"

再在後面加上命令

相關文章
相關標籤/搜索