由于依赖的关系,python
须要分别下载SIP
以及PyQt5
bash
解压,make,再安装ui
tar -xvf sip*.tar.gz python configure.py make sudo make install
安装pyqt5
须要上面的sip
,还须要qmake,也就是一个QT的环境:spa
编译须要有qmake,也就意味着咱们须要安装好QT
,再将QT5
加到环境变量~/.bash_profile
code
export PATH=/Users/fdhuang/.cabal/bin:/Users/fdhuang/Qt/5.2.1/clang_64/bin:$PATH
将下面的/Users/fdhuang/Qt/5.2.1/clang_64/bin/qmake
替换成你的目录,以及/Library/Python/2.7/site-packages/
也就是包的位置,如何查看?ip
import site; site.getsitepackages()
接着编译get
$python configure.py -q /Users/fdhuang/Qt/5.2.1/clang_64/bin/qmake -d /Library/Python/2.7/site-packages/ --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
安装qt
make sudo make install
一个简单的示例以下:it
import sysfrom PyQt5 import QtCore, QtGui, QtWidgetsif __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"
再在后面加上命令。