Why are SIP and PyQt4 not getting along

Matt picture Matt · Dec 21, 2012 · Viewed 13.4k times · Source

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.

Answer

jdi picture jdi · Dec 21, 2012

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