歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 7 下搭建Python2.7 + PyQt4.11.3 + Eric4.0開發平台

CentOS 7 下搭建Python2.7 + PyQt4.11.3 + Eric4.0開發平台

日期:2017/2/28 13:50:48   编辑:Linux教程

CentOS 7 下搭建Python2.7 + PyQt4.11.3 + Eric4.0開發平台

安裝Python2.7
CentOS 7默認安裝了Python2.7 。故Python2.7的安裝可略去

安裝Qt4.8.7

qt-everywhere-opensource-src-4.8.7.tar

# tar -zxvf qt-everywhere-opensource-src-4.8.7.tar

# cd qt-everywhere-opensource-src-4.8.7

# ./configure

# make

# make install

將/usr/bin下的qmake軟連接到/opt/Qt/5.3/gcc/bin/qmake上

ln -s /usr/local/Trolltech/Qt-4.8.7/bin/qmake /usr/bin/qmake

安裝SIP
版本 sip-4.16.7.tar

官網上說:“Before you can build PyQt4 you must have already built and installed SIP” 意思是說必須先安裝SIP,於是也下載了SIP。

解壓SIP壓縮包,進入源碼目錄,打開README,說是當前目錄下有一個build.py,結果我沒有找到。但找到了一個configure.py的代碼。於是我執行它

$ python configure.py

正常完成,並生成了Makefile。我下意識地執行make,結果:

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

$ sudo yum install python-devel

完成安裝。再make,順利通過編譯。再sudo make install,也很順利。

安裝PyQt4
版本 PyQt-x11-gpl-4.11.3.tar

解壓下載的:PyQt-x11-gpl-4.10.3.tar.gz

進入源碼目錄,打開README,按說明的步驟:先執行configure.py腳本,然後make,make install。

因為我在使用 eric4 的時候 出現錯誤

ImportError: No module named QtWebKit

原因是在編譯 PyQt 的時候 沒有安裝 QtWebKit 導致沒有編譯那個模塊

所以在編譯之前 yum install qtwebkit

$ 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.py時讓我們同意協議。輸入yes繼續。

用了1min順利完成!接著make,這個過程有一點長,花了20分鐘,很順利。

安裝QScintilla2
版本 QScintilla-gpl-2.9.tar

# tar -xzvf QScintilla-gpl-2.8.4.tar.gz

# cd QScintilla-gpl-2.8.4

1.安裝本體

# cd Qt4Qt5

# qmake qscintilla.pro

# sudo make make install

2.安裝designer

# cd ../designer-Qt4Qt5

# qmake designer.pro

# sudo make

# sudo make install

3.安裝python bingdings

# cd ../Python

# python3 configure.py

# sudo make

# sudo make install

安裝Eric4
版本 eric4-4.5.25.tar

中文包 eric4-i18n-zh_CN.GB2312-4.5.25.tar

# tar -zxvf eric6-6.0-snapshot-20140720.tar.gz

# tar -zxvf eric6-i18n-zh_CN.GB2312-6.0-snapshot-20140720.tar.gz //語言包文件會自動解壓到Eric6.0主文件解壓目錄中

# cd eric6-6.0-snapshot-20140720

# sudo python3 install.py //安裝主程序

# sudo python3 install-i18n.py //安裝中文語言包

# sudo eric4 運行

配置過程:
終端輸入eric6啟動:

1、選擇Settings -> preference -> Editor -> Autocompation。勾選所有選框;

2、選擇Settings -> preference -> Editor -> QScintilla 。勾上左右的兩個選框,然後在下面source中,選擇from Document and API files;

3、選擇Settings -> preference -> Editor -> APIs。勾選Complie APIs Autocompation,在Language中,選擇python3。點面下面的Add from installed APIs按鈕,選擇住需要的.api文件。最後點擊Compile APIs;

4、選擇Settings -> preference -> Interface -> Interface。右側Language根據喜好選擇中文或者English。重啟生效。

配置完成。

Mac OS X 10.11.1下搭建Python3.4 + PyQt5.5.1 +Eric6.1.1開發平台 http://www.linuxidc.com/Linux/2016-01/127677.htm

Ubuntu 14.04下搭建Python3.4 + PyQt5.3.2 + Eric6.0開發平台 http://www.linuxidc.com/Linux/2015-12/126176.htm

PyQt 的詳細介紹:請點這裡
PyQt 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved