Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are SIP and PyQt4 not getting along

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.

like image 787
Matt Avatar asked Dec 20 '12 23:12

Matt


2 Answers

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:

  • sip 4.14.2
  • PyQt4 4.9.6

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
like image 71
jdi Avatar answered Oct 23 '22 01:10

jdi


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
like image 1
Milean Avatar answered Oct 23 '22 00:10

Milean