Linux下源码安装PyQt4

感谢朋友支持本博客,欢迎共同探讨交流,由于能力和时间有限,错误之处在所难免,欢迎指正!
如果转载,请保留作者信息。
博客地址:http://blog.csdn.net/qq_21398167

原博文地址:http://blog.csdn.net/qq_21398167/article/details/46429655

从官网上下载PyQt的源码:

http://www.riverbankcomputing.com/software/pyqt/

官网上说:“Before you can build PyQt4 you must have already built and installed SIP” 意思是说必须先安装SIP,于是也下载了SIP。

解压SIP压缩包,进入源码目录,打开README,说是当前目录下有一个build.py,结果我没有找到。但找到了一个configure.py的代码。于是我执行它


1
$ python configure.py

正常完成,并生成了Makefile。我下意识地执行make,结果:


1
2
3
4
5
6
7
8
gcc  -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I /usr/include/python2 .6 -o siplib.o siplib.c
siplib.c:20:20: fatal error: Python.h: No such  file  or directory
  #include <Python.h>
                     ^
compilation terminated.
make [1]: *** [siplib.o] Error 1
make [1]: Leaving directory ` /home/hevake_lcj/Install/qt-downloads/sip-4 .15.3 /siplib '
make : *** [all] Error 2

通常这种问题出在系统没有安装组件的开发板,只提供了库文件,并没有提供对应的头文件,不能进行二次开发。解决文件就是安装python-devel


1
sudo  yum  install  python-devel

完成安装。再make,顺利通过编译。再sudo make install,也很顺利。测试是否完成安装:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ sip -h
Usage:
     sip [-h] [-V] [-a  file ] [-b  file ] [-c  dir ] [-d  file ] [-e] [-g] [-I  dir ] [-j  #] [-k] [-m file] [-o] [-p module] [-P] [-r] [-s suffix] [-t tag] [-T] [-w] [-x feature] [-X id:file] [-z file] [file]
where:
     -h          display this help message
     -V          display the sip version number
     -a  file      the name of the QScintilla API  file  [default not generated]
     -b  file      the name of the build  file  [default none generated]
     -c  dir       the name of the code directory [default not generated]
     -d  file      the name of the documentation  file  (deprecated) [default not generated]
     -e           enable  support  for  exceptions [default disabled]
     -g          always release and reacquire the GIL [default only when specified]
     -I  dir       look  in  this directory when including files
     -j  #        split the generated code into # files [default 1 per class]
     -k          support keyword arguments  in  functions and methods
     -m  file      the name of the XML  export  file  [default not generated]
     -o           enable  the automatic generation of docstrings [default disabled]
     -p module   the name of the consolidated module that this is a component of
     -P           enable  the protected /public  hack
     -r          generate code with tracing enabled [default disabled]
     -s suffix   the suffix to use  for  C or C++  source  files [default  ".c"  or  ".cpp" ]
     -t tag      the version /platform  to generate code  for
     -T          disable the timestamp  in  the header of generated files
     -w           enable  warning messages
     -x feature  this feature is disabled
     -X  id : file   create the extracts  for  an  id  in  file
     -z  file      the name of a  file  containing  more  command  line flags
     file         the name of the specification  file  [default stdin]

安装OK。


解压下载的:PyQt-x11-gpl-4.10.3.tar.gz

ImportError: No module named QtWebKit

进入源码目录,打开README,按说明的步骤:先执行configure-ng.py脚本,然后make,make install。

因为我在使用 eric4 的时候   出现错误

ImportError: No module named QtWebKit

原因是在编译 PyQt 的时候  没有安装 QtWebKit   导致没有编译那个模块
 
所以在编译之前   yum install qtwebkit
1
2
3
4
5
6
7
8
9
10
11
12
$ python configure-ng.py 
Querying qmake about your Qt installation...
Determining the details of your Qt installation...
This is the GPL version of PyQt 4.10.3 (licensed under the GNU General Public
License)  for  Python 2.6.6 on linux2.
 
Type  '2'  to view the GPL v2 license.
Type  '3'  to view the GPL v3 license.
Type  'yes'  to accept the terms of the license.
Type  'no'  to decline the terms of the license.
 
Do you accept the terms of the license?  yes



由于这是GPL,所以在执行configure-ng.py时让我们同意协议。输入yes继续。

用了1min顺利完成!接着make,这个过程有一点长,花了20分钟,很顺利。


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值