安装 Qt
1 |
brew install qt |
测试安装结果,需要正确找到 qmake 的路径
1 |
qmake (安装完我输qmake没反应,需要到qt的安装路径去找#/usr/local/Cellar/qt/5.9.1/bin/qmake) |
安装 SIP
下载(sip-4.18.1.tar.gz): https://riverbankcomputing.com/software/sip/download (我用迅雷下的用tar解压不了,用浏览器默认下载的正常)
1 2 3 4 5 6 7 |
tar -xzf sip-4.18.1.tar.gz cd sip-4.18.1 python configure.py -d /Library/Python/2.7/site-packages --arch=x86_64 make sudo make install |
如果 sudo make install 的时候报如下错误
1 2 3 4 |
cp -f sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip cp: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip: Operation not permitted make[1]: *** [install] Error 1 make: *** [install] Error 2 |
#解决方法
#重启 Mac
#按住 Command + R 直到出现苹果 Logo
#进入 Recoverary 模式
#菜单栏 > 实用工具 > 终端
#输入 csrutil disable (如果想再次改回来,输入 csrutil enable)
#重启 Mac
PyQt4
下载(PyQt-mac-gpl-4.11.4.tar.gz): https://riverbankcomputing.com/software/pyqt/download (我用迅雷下的用tar解压不了,用浏览器默认下载的正常)
查看 qmake 路径
1 2 |
which qmake #/usr/local/bin/qmake (我使用which qmake找不到qmake路径,需要到qt的安装路径去找#/usr/local/Cellar/qt/5.9.1/bin/qmake) |
安装
安装时出现报错:Error: This version of PyQt4 and the commercial version of Qt have incompatible licenses.
解决方法:注释掉configure-ng.py下面语句即可:
1 2 3 4 |
if introspecting and target_config.qt_licensee not in OPEN_SOURCE_LICENSEES and ltype == 'GPL': error( "This version of PyQt4 and the commercial version of Qt have " "incompatible licenses.") |
1 2 3 4 5 6 7 |
tar -xzf PyQt-mac-gpl-4.11.4.tar.gz cd PyQt-mac-gpl-4.11.4 python configure-ng.py -q /usr/local/bin/qmake -d /Library/Python/2.7/site-packages/ --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip make sudo make install |
测试
1 |
import PyQt4 |