Python-Mac 安装 PyQt4-转

原文地址:http://www.cnblogs.com/JohnABC/p/6232973.html   下面内容略微不同

环境:

  系统: OS X 10.11.4

  Python: 2.7.10

1.安装 Qt

brew install qt

  测试安装结果,需要正确找到 qmake 的路径

qmake (安装完我输qmake没反应,需要到qt的安装路径去找#/usr/local/Cellar/qt/5.9.1/bin/qmake)

2.安装 SIP 

  下载(sip-4.18.1.tar.gz): https://riverbankcomputing.com/software/sip/download (我用迅雷下的用tar解压不了,用浏览器默认下载的正常)

复制代码
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 的时候报如下错误

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

3.PyQt4

  下载(PyQt-mac-gpl-4.11.4.tar.gz): https://riverbankcomputing.com/software/pyqt/download (我用迅雷下的用tar解压不了,用浏览器默认下载的正常)

  查看 qmake 路径

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下面语句即可:

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.")

 

复制代码
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
复制代码

4.测试

import PyQt4

转载于:https://www.cnblogs.com/v-BigdoG-v/p/7264162.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值