PyQt4 on mac os x

Through work i needed to install pyqt4 on a mac os x (snow leopard). So i went to nokia.com and downloaded the latest qt-sdk (sdk: 1.1.3, libqt: 4.7.4), then to riverbank computing and downloaded sip (needed for installing pyqt4) and pyqt4. After installing the standard way i tried a hello world but couldn’t import anything from PyQt4. The module was installed but i could not use it. To make this more google-friendly this is the error i got:

Traceback (most recent call last):
  File "qt-test.py", line 4, in <module>
    from PyQt4 import QtGui
ImportError: cannot import name QtGui

I googled around and found this blog which informed me that when installing PyQt4 you have to explicitly define the path to qmake, site-packages and the arch. if you use python shipped with os x and installed the sdk to its standard path then the command to configure pyqt4 should probably be

python configure.py -q /Users/<USERNAME>/QtSDK/Desktop/Qt/474/gcc/bin/qmake -d /Library/Python/2.6/site-packages -g --use-arch x86_64

of course this assumes you have a 64bit os.

// sluggo

  1. AbiusX Says:

    Happy that my post was useful for you.

    ----------

Comment