Ubuntu 14.04下搭建Python3.4 + PyQt5.3.2 + Eric6.0开发平台(2)

the sip module implements API v11.0 but the PyQt5.QtCore module requires API v11.1 

the sip module implements API v11.0 but the PyQt5.QtCore module requires API v11.1

Ubuntu 14.04下搭建Python3.4 + PyQt5.3.2 + Eric6.0开发平台

安装PyQt5

PyQt是Python的一个跨平台图形开发工具集,是Python与Qt的成功融合。PyQt包含了大约440个类、超过6000个的函数和方法,灰常强大。需要注意的是,Eric(一种Python IDE,依赖PyQt)当前最新的稳定版Eric5只支持PyQt4(确切的说是PyQt4.8以上5.0以下),支持PyQt5的Eric版本现在仅为Eric6.0 snapshot版,该版本包含最新的Eric5的所有功能,但稳定性需要测试。如果你希望使用稳定的Eric5,请在此步骤安装PyQt4的最新版PyQt4.11.2。这里我们安装PyQt5.3.2.

PyQt5.3.2下载: 安装过程:

tar -zxvf PyQt-gpl-5.3.2.tar.gz 

cd PyQt-gpl-5.3.2 

python3 configure.py     

tar -zxvf PyQt-gpl-5.3.2.tar.gz cd PyQt-gpl-5.3.2 python3 configure.py

注意:此命令生成各种Qt模块后,其中的QtWebKitWidgets模块由于Qt4和Qt5的qprinter.h所属模块的调整(Qt4存在于QtGui中,Qt5将其调整到QtPrintSupport中了),QtWebKitWidgets的Makefile中缺失了对QtPrintSupport的头文件目录引用,会导致后面编译PyQt5时无法找到qprinter.h头文件,编译失败(编译过程非常漫长):

qprinter.h: No such file or directory 

qprinter.h: No such file or directory

所以需要向刚生成的QtWebKitWidgets模块源文件的MakeFile文件的INCPATH中添加QtPrintSupport引用。

原INCPATH为:

INCPATH       = -I/opt/Qt/5.3/gcc/mkspecs/linux-g++ -I. -I. -I/usr/include/python3.4m -I/opt/Qt/5.3/gcc/include -I/opt/Qt/5.3/gcc/include/QtWebKitWidgets -I/opt/Qt/5.3/gcc/include/QtWebKit -I/opt/Qt/5.3/gcc/include/QtWidgets -I/opt/Qt/5.3/gcc/include/QtNetwork -I/opt/Qt/5.3/gcc/include/QtGui -I/opt/Qt/5.3/gcc/include/QtCore -I. 

INCPATH = -I/opt/Qt/5.3/gcc/mkspecs/linux-g++ -I. -I. -I/usr/include/python3.4m -I/opt/Qt/5.3/gcc/include -I/opt/Qt/5.3/gcc/include/QtWebKitWidgets -I/opt/Qt/5.3/gcc/include/QtWebKit -I/opt/Qt/5.3/gcc/include/QtWidgets -I/opt/Qt/5.3/gcc/include/QtNetwork -I/opt/Qt/5.3/gcc/include/QtGui -I/opt/Qt/5.3/gcc/include/QtCore -I.

修改为:

INCPATH       = -I/opt/Qt/5.3/gcc/mkspecs/linux-g++ -I. -I. -I/usr/include/python3.4m -I/opt/Qt/5.3/gcc/include -I/opt/Qt/5.3/gcc/include/QtWebKitWidgets -I/opt/Qt/5.3/gcc/include/QtWebKit -I/opt/Qt/5.3/gcc/include/QtWidgets -I/opt/Qt/5.3/gcc/include/QtNetwork -I/opt/Qt/5.3/gcc/include/QtPrintSupport -I/opt/Qt/5.3/gcc/include/QtGui -I/opt/Qt/5.3/gcc/include/QtCore -I. 

INCPATH = -I/opt/Qt/5.3/gcc/mkspecs/linux-g++ -I. -I. -I/usr/include/python3.4m -I/opt/Qt/5.3/gcc/include -I/opt/Qt/5.3/gcc/include/QtWebKitWidgets -I/opt/Qt/5.3/gcc/include/QtWebKit -I/opt/Qt/5.3/gcc/include/QtWidgets -I/opt/Qt/5.3/gcc/include/QtNetwork -I/opt/Qt/5.3/gcc/include/QtPrintSupport -I/opt/Qt/5.3/gcc/include/QtGui -I/opt/Qt/5.3/gcc/include/QtCore -I.

或者可以直接在QtWebKitWidgets模块源文件的QtWebKitWidgets.pro文件中加入:

QT += printsupport 

QT += printsupport

也行。

接下来执行编译安装:

sudo make   

sudo make install 

sudo make sudo make install

配置过程:

安装完成后进入Python3环境验证是否安装成功:

>>>import PyQt5 

>>>import PyQt5

如果提示不存在PyQt5模块,表示安装的PyQt5没有被python3正确识别。默认的安装路径为python的site-packages目录。通常python3的模块安装路径会分成2个,一个/usr/lib/python3,一个/usr/lib/python3.4,两个路径下的模块都能被python3环境正确调用,但是python3.4的site-packages目录下的模块貌似无法调用。PyQt5偏偏默认安装到此目录了。解决办法是为其创建软连接,保险起见,python3目录和python3.4目录分别创建一个:

sudo ln -s /usr/lib/python3.4/site-packages/PyQt5 /usr/lib/python3.4/PyQt5 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8eacff593f9b6f57f185d5a00eddff67.html