PyQt and Pydev in Eclipse on Snow Leopard

It’s been a while since I’ve done anything useful with Python, but just the other day I felt a sudden urge to pick it up again. I needed to get my old development environment with PyQt4 and Pydev up and running. I downloaded the latest version of Sip and PyQt from Riverbank, Qt (the mac-cocoa package) from Nokia and went through a straight forward install. After checking that I could import QtCore and QtGui in Idle, I installed the latest version of Pydev in Eclipse and opened one of my old projects…. Python crashed with the following error ‘Python quit unexpectedly while using the Qt.so plug-in’ and my project was filled with unresolved import errors. I thought that I had run into some 32- vs 64 bit issues, and started to build everything from source. I went through the whole install process several times building different versions of Qt from source and switching back and forth between 32 and 64 bit installs and Python versions, but no avail. After some late night Googling I found a post at Pydev’s tracker on Sourceforge suggesting to turn off code analysis in Pydev, due to a bug in PyQt4(I think). With code analysis off everything worked. I am not sure if it’s only because of the code analysis setting, or if it’s a mix of that and the versions of Qt, PyQt and Python I just happened to be running at the time. I have put together a list of what I installed and how. If you already have everything installed, but with different versions of the software, try and turn off code analysis. If that doesn’t help maybe this setup will. If you have some more info regarding these issues, please leave a comment.

Updated December 3, 2009
Nokia released Qt 4.6 December 1st, so I upgraded. I have now also upgraded sip to 4.9.3 and PyQt to 4.6.2. I did exactly the same steps as before, and I haven’t had any ‘Python crashes’ yet… Code completion of PyQt modules doesn’t work though.
Post is now updated to reflect the new releases of Qt, sip and PyQt.

Any feedback is greatly appreciated. Does this work for you?

-Hersson-

Updated November 27, 2009
After using this setup for a few days I am sorry to say that this does NOT work. Python still quits ‘unexpectedly while using the Qt.so plug-in’. Maybe not as often, but the problem is still very much present. I apologies for spreading bogus info. If you know how to remedy this annoyance please leave a comment.

Post will be updated as soon as I find or hear about a workaround.

-Hersson-

First of all I am running the Python 2.6.1 64 bit version shipped with Snow Leopard, and the 64 bit Cocoa version of Eclipse 3.5.1

Pre-phase
Download the qt-mac-cocoa-opensource-4.6.0.dmg binary from Nokia (this is the first version of Qt that officially supports Snow Leopard). Then sip-4.9.3.tar.gz and PyQt-mac-gpl-4.6.2.tar.gz from Riverbank,

Qt
I did a default install, but without the examples and documentation.

SIP

tar zxvf sip-4.9.3.tar.gz
cd sip-4.9.3
python configure.py --arch=x86_64
make 
sudo make install

PyQt4

tar zxvf PyQt-mac-gpl-4.6.2.tar.gz
cd PyQt-mac-gpl-4.6.2
python configure.py --use-arch=x86_64  -q /usr/bin/qmake
make
sudo make install

Pydev
Start Eclipse and go to Help -> Install New Software. Add http://pydev.org/updates, and install the latest version (1.5.1 as of writing).
Then setup your python interpreter, Auto Config should go right and choose 2.6.
Now disable code analysis: Open Eclipse Preferences -> Pydev -> Editor -> Code Analysis and uncheck Do code analysis?

  • Twitter
  • Facebook
  • del.icio.us
  • Digg
  • Google Bookmarks
  • StumbleUpon
  • FriendFeed

10 thoughts on “PyQt and Pydev in Eclipse on Snow Leopard

    1. Fabio,

      thank you so much for the info and the links.
      I tried running your code in Idle. It didn’t crash

      IDLE 2.6.1      
      >>> from PyQt4.QtCore import *
      >>> QSignalMapper
      <class 'PyQt4.QtCore.QSignalMapper'>
      >>> import inspect
      >>> inspect.ismodule(QSignalMapper)
      False
      >>>

      Cheers,

      Hersson

  1. I tried this using PyQT 4.6.2 (the latest available on the Riverbank site). I got through the PyQT ‘make’ step. The compilation errors out after a while, saying that /Library/Frameworks/Python.framework/Python is missing the architecture x86_64. The compiler then spits out a long list of missing symbols. Do you have any idea what may be going wrong for me?

    1. Jeff,

      is your Mac capable of running 64bit applications? (Do you have a Core 2 Duo or later CPU)
      If yes, which version of Python are you running?

      I upgraded to sip 4.9.3 and PyQt 4.6.2 after reading your comment. Using the same settings as before, they both installed without problems.

      -Hersson-

  2. Herrson,

    I have a Macbook Pro, Core 2 Duo. The version info that shows up in Terminal when I start Python is, “Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin”. I believe that is the Snow Leopard installed version of Python, but I might be mistaken.

    1. Hi Jeff.

      You are not mistaken, that is the version that ships with Snow Leopard. Then I have no idea why it doesn’t build.

      Please note that I have updated the post today. My setup doesn’t work either.
      Sorry.

      -Hersson-

  3. Well, I got it to compile. I reinstalled XCode and it worked. I’m not getting the Python interpreter crash with PyQt4 that Fabio is describing on his linked blog pages. I haven’t tried to do much in Eclipse yet, though. It may still all go south on me.

    1. Nice :-)

      I would really like to hear about your experiences when you get to try out Eclipse a bit more. Especially since I thought things were ok when I started out, and then later found out it was not.

      Cheers,

      Hersson

  4. Here are some early results from using PyDev with the latest PyQt and SIP

    If I create a PyDev project in Eclipse by pointing to an existing project folder (freshly sync’d from Git) and tell PyDev to create a ‘src’ folder (even though one already exists in the parent project folder) I get massive numbers of import errors and a project that will not run.

    If I blow away that PyDev project and recreate it, again pointing it at the existing project folder, but tell it to not create the ‘src’ folder (because one already exsists), the project creates successfully, all of my Python source code is available, and the project does not have errors. It appears to run correctly, too.

Leave a Reply

Your email address will not be published. Required fields are marked *


eight × = 64

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>