8

Feedback

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).

Plateform:

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

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

Installation steps :

  • 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

Package Locations :

  • Qt-5.2.1 root directory : /opt/Qt/5.2.1/gcc_64
  • PyQt5 root directory : /usr/lib/python3.3/site-packages

Sip Version

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

My python environment variable is :

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

The $PATH varaible :

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 is empty (don't think it's important but I prefer to mention it... )

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

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. ...

please help.

Thanks in advance.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Emmanuel BRUNET
  • 1,286
  • 3
  • 19
  • 46
  • This means the python sip module installed is too old, or maybe a previously installed module is found. What does `import sip; print(sip, sip.SIP_VERSION_STR)` say? – mata Mar 23 '14 at 18:01
  • In fact yes. I did a lot of changes but after removing the python3-sip package, I can import QtCore, QtNetwork – Emmanuel BRUNET Mar 23 '14 at 22:00
  • Thanks for your reply mata. My problem is the same as mentioned here : [http://www.riverbankcomputing.com/pipermail/pyqt/2013-July/033011.html] . But with no answer – Emmanuel BRUNET Mar 23 '14 at 22:10
  • the output of your command is (now ?) ` 4.15.5` – Emmanuel BRUNET Mar 23 '14 at 22:12
  • Are you sure all modules (QtGui, QtWidgets ...) were compiled and installed when you built Qt? pyqt can only be build the bindings against the libraries which are installed... – mata Mar 23 '14 at 22:59
  • Yes mata there are all located in the /opt/qt/5.2.1/gcc_64/lib, I've open a new post on this topic. Could you please have a quick look ? thanks in advance [http://stackoverflow.com/questions/22598333/pyqt5-error-import-qtwidgets-qtgui] – Emmanuel BRUNET Mar 23 '14 at 23:30

2 Answers2

13

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

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.

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).

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)

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

Chaos_99
  • 2,284
  • 2
  • 25
  • 29
  • Thanks for your answer Chaos. In fact, I solved the problem by removing the python3-sip package that uses the wrong sip version , if I remember correctly. see http://hznteam.fr/trac-bubble/ticket/102 – Emmanuel BRUNET Apr 07 '14 at 20:30
  • 2
    Thanks a lot you saved my life ! For those who encounter this error : **RuntimeError: the sip module implements API v11.0 but the PyQt5.QtCore module requires API v11.2** This answer solve the issue. – WannaGetHigh Aug 26 '15 at 10:11
  • so far I can't seem to be able to reverse this misshap. I too compiled PyQt5 and Sip after QT5 as I was instructed from a tutorial (there really should be warnings on https://wiki.qt.io/Install_Qt_5_on_Ubuntu agaisnt this to clear everything up) I found online and while sip packages remove fairly easily enough the same can't be said for PyQt5 and QT5 will re-running the QT5 installer do the trick? – tatsu Jul 08 '17 at 23:34
  • This is great! Works for python 2 & PyQt4 too. In my case I installed PyQt4 and sip from source but forgot to remove their reciprocal Ubuntu packages I had installed earlier. – undercat Mar 22 '18 at 09:40
0

I'm posting here because cannot comment yet. For whomever has this problem in Windows, for me the sip version shown by import sip print(sip, sip.SIP_VERSION_STR) was lower than the version shown in the sip file names. I fixed it by uninstalling and reinstalling sip (pip uninstall sip).

R01k
  • 735
  • 3
  • 12
  • 26