pyqt5在mac os 安裝

PyQT5 手動安裝

由於依賴的關係,python

須要分別下載SIP以及PyQt5bash

SIP Download
PyQt5app

python sip install

解壓,make,再安裝ui

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

pyqt5 install

安裝pyqt5須要上面的sip,還須要qmake,也就是一個QT的環境:spa

編譯須要有qmake,也就意味着咱們須要安裝好QT,再將QT5加到環境變量~/.bash_profilecode

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"

再在後面加上命令。

相關文章
相關標籤/搜索