Linux下源碼安裝PyQt4

來源:互聯網
上載者:User

標籤:pyqt   python   

從官網上下載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,結果:


12345678 gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/include/python2.6 -o siplib.o siplib.csiplib.c:20:20: fatal error: Python.h: No such file or directory #include <Python.h>                    ^compilation terminated.make[1]: *** [siplib.o] Error 1make[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,也很順利。測試是否完成安裝:


12345678910111213141516171819202122232425262728 $ sip -hUsage:    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。


123456789101112 $ 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 PublicLicense) 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分鐘,很順利。


Linux下源碼安裝PyQt4

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.