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"

再在后面加上命令。

相关文章
相关标签/搜索