Study PyQt from beginning

需要安装PyQt ,(MacOs自带Python, 需要下载安装Qt 4环境,在Mac 中安装Qt4,推荐使用mpkg安装文件,这个文件需要用右键Open,直接双击打开会被block)。

其次考虑开发环境,普通人都需要开发环境,aren't we? 于是搜了下,看到大家都用Eric, 其主页写着:

Eric is a full featured Python and Ruby editor and IDE, written in python. It is based on the cross platform Qt gui toolkit, integrating the highly flexible Scintilla editor control.

行了,有这些描述,足够使Eric作为不二之选。

另,如果开发django应用,建议首选aptana,很好用。

Eric有4和5两个版本,Eric5要求Python3.1以上,不过目前主流的Python都是2.x, 因此选4

对应的PyQt4也要求Qt4。


检查Qt4环境,可以使用

$ qmake -v

QMake version 2.01a

Using Qt version 4.8.5 in /Library/Frameworks

安装PyQt4

$ python configure-ng.py -d /Library/Python/2.7/site-packets/ --sip 

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip

注意-d参数很重要,安装后不用调整环境变量,否则很麻烦。


$ make 

编译时总是报  #    warning "This version of Mac OS X is unsupported" 估计还没有支持到10.9,于是,修改

/Library/Frameworks/QtCore.framework/Headers/qglobal.h 修改331行为:

#  if !defined(MAC_OS_X_VERSION_10_9)

#       define MAC_OS_X_VERSION_10_9 MAC_OS_X_VERSION_10_8 + 1

#  endif

#  if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9)

#    warning "This version of Mac OS X is unsupported"

#  endif

相当于增加定义了 MAC_OS_X_VERSION_10_9宏,再次编译,就没那个警告了

不知道有没有问题


$ sudo make install


安装验证:

$ python

Python 2.7.5 (default, Aug 25 2013, 00:04:04) 

[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import PyQt4

>>> quit()


重点时import PyQt4没有报错。



最后,安装Eric4

$ sudo python install.py

Checking dependencies

Python Version: 2.7.5

Found PyQt4

Found QtHelp

Sorry, please install QScintilla2 and

its PyQt4 wrapper.

Error: cannot import name Qsci

重新在pyQt官方网站下载  QScintilla2

安装方法:

    cd Qt4Qt5
    qmake qscintilla.pro  -spec macx-g++  (注意这个参数是mac机用的,其他linux不用)
    make
    sudo make install
之后binding python

在QScintilla2目录下有个python目录

执行 python configure.py --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip

make

sudo make install

在进入到 

designer-Qt4Qt5 目录

    qmake designer.pro  -spec macx-g++  (注意这个参数是mac机用的,其他linux不用)
    make
    sudo make install

注意,要把Qsci.so文件拷贝到 /Library/Python/2.7/site-packets/PyQt4/目录下,否则还是找不到会报

Error: cannot import name Qsci 错误


最后,在eric4安装目录下 sudo python install.py 安装完成。


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值