2011-06-15

Fix for Quantum GIS and Python bindings mismatch in Ubuntu 10.10

I'm one version behind on my Ubuntu distro (I've decided to wait until the next LTS before upgrading again, since I really need the time to get work done), so this may not be applicable to the latest version of Ubuntu (11.04). In any case, I recently noticed that Quantum GIS (QGIS) installed from the Ubutnu GIS 'unstable' repository was unable to link to the "Python/C++ bindings generator runtime library" (python-sip).  The reported error when starting QGIS is as follows:


Traceback (most recent call last):
  File "", line 1, in RuntimeError: the sip module implements API v8.0 but the qgis.core module requires API v7.1


This shouldn't be a big surprise, since QGIS is being installed from a repository deliberately labelled 'unstable'. However, I was not interested in downgrading QGIS and/or any of the other packages that I draw from the Ubuntu GIS repository, and as far as I can tell, 'unstable' for this repository usually just means 'up-to-date', considering that the projects delivered through this repository are high quality as far as I am aware.  Although, using this repo does require a bit of care; you may have to account for significant changes in new software versions in any dependent applications you have (e.g., MapServer brought a number of changes in the latest 6.0 release, which would have required users/web developers to update their mapfiles and/or scripted code).


After a bit of googling around, I eventually found that I needed to downgrade two packages to maintain compatibility with QGIS: python-sip and python-qt4. I don't recall the original source (this was a few months ago), but if you a) want the latest Open Source GIS packages, and b) want to be able to use python-based capabilities/plug-ins on Ubuntu 10.10, then here's the steps:

1. If you don't have it already, setup the Ubuntu GIS unstable repo, and install the latest QGIS package (1.7.0 at the time of this writing):


    # sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
    # sudo apt-get install qgis


2. Downgrade python-sip and python-qt4:

    # sudo apt-get install python-sip=4.10.5-0ubuntu1 python-qt4=4.7.4-0ubuntu1

3. If this works for you, you can consider 'pinning' the versions of these two packages so they don't get replaced the next time you install updates.  You can choose whichever method is most appropriate for you here: https://help.ubuntu.com/community/PinningHowto

I should note that QGIS will run without downgrading these python packages (albeit, after reporting the Python API errors on each startup).  However, it will be necessary if you want to use plug-ins that require Python (e.g., the OpenLayers plugin - I've been using this version: https://github.com/TheGeoist/qgis-openlayers-plugin/).

I'd be interested to know if anyone has run into this problem with Ubuntu 11.04.