PyQt5 - SIP API 10 级错误.需要 API 11 [英] PyQt5 - SIP API 10 level error. API 11 required

查看:35
本文介绍了PyQt5 - SIP API 10 级错误.需要 API 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反馈

我正在使用兼容 PyQt5 (>= 3.3.2) 的标准 Python3 (3.3.2+) 解释器安装 PyQt5(基于 Qt5.2.1/Sip 4.15.5 API 11 ???)因为无法在 Ubuntu 12.04 上编译 Python3.3-5,然后无法安装 PyQt5(python 3.3.2 或更高版本).

I'm working on a PyQt5 installation (based on Qt5.2.1 / Sip 4.15.5 API 11 ???) with the standard Python3 (3.3.2+) interpreter that is PyQt5 compliant (>= 3.3.2) as It's not possible to compile Python3.3-5 on Ubuntu 12.04 and then impossible to install PyQt5 (python 3.3.2 or later).

平台:

jeby6372@mercure:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 13.10
Release:    13.10
Codename:   saucy
jeby6372@mercure:~$ uname -a
Linux mercure 3.11.0-13-generic #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

在安装过程中似乎一切正常,PyQt5 导入工作,但是当我尝试通过 python3 解释器导入模块时,出现此错误:

Everything seemed to work fine during the installation, the PyQt5 import works but when I try a module import thru the python3 interpreter, this error is raised:

>>> import PyQt5
>>> from PyQt5.QtCore import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: the sip module implements API v10.0 to v10.1 but the PyQt5.QtCore module requires API v11.0

安装步骤:

  • 使用标准 X64 linux 安装程序安装 Qt5.2.1
  • 从源代码安装 SIP 4.15.5
  • PyQt5 来自如 RiverBank 程序中所述编译的源代码,针对 compile.py 选项中的 qmake 程序:

  • Qt5.2.1 installed with the standard X64 linux installer
  • SIP 4.15.5 installation from sources
  • PyQt5 from sources compiled as mentioned in the RiverBank procedure, targeting the qmake program in the compile.py options :

python3 configure.py --qmake/opt/Qt/5.2.1/gcc_64/bin/qmake --sip/usr/bin/sip

python3 configure.py --qmake /opt/Qt/5.2.1/gcc_64/bin/qmake --sip /usr/bin/sip

包裹位置:

  • Qt-5.2.1 根目录:/opt/Qt/5.2.1/gcc_64
  • PyQt5 根目录:/usr/lib/python3.3/site-packages

Sip 版本

jeby6372@mercure:~$ which sip
/usr/bin/sip
jeby6372@mercure:~$ sip -V
4.15.5
jeby6372@mercure:~$ 

我的python环境变量是:

My python environment variable is :

jeby6372@mercure:~$ echo $PYTHONPATH
/usr/lib/python3.3/site-packages

$PATH 变量:

jeby6372@mercure:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/Qt/5.2.1/gcc_64/bin

$LD_LIBRARY_PATH 是空的(不认为它很重要,但我更愿意提及它...)

$LD_LIBRARY_PATH is empty (don't think it's important but I prefer to mention it... )

site-pacakges 目录的内容是:

The content of the site-pacakges dir is :

jeby6372@mercure:~$ ls /usr/lib/python3.3/site-packages
PyQt5

__init__.py  QtCore.so  QtDBus.so  QtNetwork.so  Qt.so  QtXmlPatterns.so  uic

但在以前的安装中它是不同的.不知道为什么!:

but in a previous installation it was different. Don't know why ! :

jeby6372@mercure:~$ ls /usr/lib/python3.3/site-packages/PyQt5
__init__.py               QtDesigner.so           QtNetwork.so       QtQuick.so       QtSvg.so        QtXmlPatterns.so
_QOpenGLFunctions_2_0.so  QtGui.so                QtOpenGL.so        QtSensors.so     QtTest.so       uic
QtBluetooth.so            QtHelp.so               QtPositioning.so   QtSerialPort.so  QtWebKit.so
QtCore.so                 QtMultimedia.so         QtPrintSupport.so  Qt.so            QtWidgets.so
QtDBus.so                 QtMultimediaWidgets.so  QtQml.so           QtSql.so         QtX11Extras.so

我不知道问题出在哪里,我在这个产品上工作的越多,我理解的就越少.我正在 Ubuntu 13.10 上进行此安装,因为 PyQt5 由于 Python 3.3-5 编译错误而无法在 Ubuntu 12.04 上运行......仍然没有答案....

I can't figure out where the problem is, The more I work on this product the less I understand. I'm doing this installation on Ubuntu 13.10 because PyQt5 doesn't work on Ubuntu 12.04 due to Python 3.3-5 compilation errors .. Still with no answer yet. ...

请帮忙.

提前致谢.

推荐答案

您的问题来自发行版提供的 sip 和您可能从源代码编译的 sip 的冲突.

Your problem comes from a clash of the distribution-supplied sip and the sip you probably compiled from sources.

按照用户mata的建议,调用import sip;print(sip, sip.SIP_VERSION_STR) 从 python3 解释器控制台中,并将输出与从普通(bash)控制台调用 sip -V 得到的输出进行比较.版本可能不同.

As sugested by user mata, call import sip; print(sip, sip.SIP_VERSION_STR) from within a python3 interpreter console and compare the output to the one you get from calling sip -V from a normal (bash) console. The versions probably differ.

我通过识别系统中所有已安装的与 sip 相关的软件包克服了该错误.(对于类似 Debian 的系统:dpkg -l | grep sip),删除它们及其所有配置文件(再次,对于 Debian:apt-get purge python3-sip python3-sip-dev ...) 并重新安装自定义版本(通过再次运行 make install).

I overcame that error by identifying all installed sip-related packages in my system. (For Debian-like systems: dpkg -l | grep sip), removed them and all their configuration files (again, for Debian: apt-get purge python3-sip python3-sip-dev ...) and re-installed the custom version (by running make install again).

顺便说一句,我对所有 PyQt5 包也做了同样的事情.根据您不完整的站点包列表,您可能还安装了一些较旧的 PyQt5 发行包.目前的有更多的模块.(以 QtSql 为例)

I by the way also did the same for all PyQt5 packages. According to your incomplete site-packages listing, you also might have installed some older PyQt5 distro package. The current one has many more modules. (QtSql for instance)

(所有提到的命令都应该以root身份执行.)

(All mentioned command should probably be executed as root.)

这篇关于PyQt5 - SIP API 10 级错误.需要 API 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆