Why are SIP and PyQt4 not getting along
Asked Answered
H

2

6

I do most of my work in Windows and have a good python27 set up like I like it. I recently installed virtualBox and got a Ubuntu Machine running on it and am trying to get PyQt4 installed on it. I installed from apt-get and updated everything, however, when I try to import from PyQt4

from PyQt4 import QtCore

I get a runtimeError:

RuntimeError: the sip module implements API v9.0 to v9.1 but the PyQt4.QtCore module requires API v8.1

I am sure this is a problem that I would have the knowledge base to solve in Windows, but my Linux inexperience is getting the better of me here and I have installed something incorrectly. The error leads me to believe I have a SIP version that is too fancy for my PyQt version...anybody have any experience with this?

Edit: If I try the import again after receiving the error it seems to work. Doing this I obtained the version info.

cfg.pyqt_version_str
Out[9]: '4.9.3'
cfg.sip_version_str
Out[10]: '4.14.3-snapshot-55188026fe6d'

Not sure what all that snapshot business is about.

Hydranth answered 20/12, 2012 at 23:7 Comment(7)
@gertvdijk: Where did you get that it is the "successor"? Keep in mind that Nokia sold off Qt to Digia which means the open-source aspects could still be a "?", while none of this has impacted Riverbanks course at all. One is just LGPL while the other is GPL. PyQt is actively maintained.Veats
Possibly not in this case, but I have run into situations where I need it. I.E. compatibility issues with Spyder during certain times in it's development for one. PySide can't implement PyQt until PyQt comes out of courseHydranth
Do you know what version of PyQt you have installed vs the sip version?Veats
well, that's where me not being great at Linux hurts me...I just did a apt-cache search pyqt sudo apt-get install python-qt4Hydranth
Did you install sip manually or did it come from apt-get? For some reason, it used the development snapshot of sip 4.14.3 which isn't probably the best idea because your PyQt is not the latest versionVeats
I downloaded it with pip and then it failed so I compiled it from sourceHydranth
ya so you probably have some conflicting version now. Can you try and remove it all and just take one route or another?Veats
V
5

I just tested an install of sip/pyqt via apt-get and it installed:

  • sip 4.12.4
  • PyQt4 4.8.5

The sip version you are reporting is a development snapshot. I recommend removing all of it, doing a sudo apt-get update and then sudo apt-get install python-sip python-qt4 again.

Otherwise, you can do the latest stable version from source:

If you have mixed installations, try and remove all of that. With pip you can do pip remove sip. Or you can go into a python shell and find out where it is, then manually remove it:

$ python
>>> import sip
>>> print sip 
# path to sip
Veats answered 21/12, 2012 at 1:48 Comment(0)
H
1

If you need to use Qt 4.7, these version work together (build worked on x86_64 Centos6)

    PyQt 4.10.4
    SIP 4.15.5
    QT 4.7.4

If you need Qt 4.8, these versions worked together for a build of PyQt4:

    PyQt 4.11
    SIP 4.16
    QT 4.8.x

Using these steps to build PyQt4:

    python configure-ng.py -g
    make
    make install
Hillinck answered 20/6, 2014 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.