Linux下源码安装PyQt4
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 a 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
进入源码目录,打开README,按说明的步骤:先执行configure-ng.py脚本,然后make,make install。
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分钟,很顺利。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。