So i recently started messing around with pyqt4 and python, and i wanted it to work on my mac, but to my dismay i had to compile it from source.
So, here is how i did it. You will need some things
You will probably need XCode so you get access to gcc and other things. You can get it from here: http://developer.apple.com/xcode/ (you either need to pay 5 dollars for xcode 4 or look for a link on that page saying “looking for xcode 3?” which is free.)
First, download and install the QT SDK here: http://qt.nokia.com/downloads I would put it somewhere in your home folder, I put it in ~/Programs/QtSDK
Now, you need to download the source tarballs (the Mac OSX / Linux ones) for PyQT4 and SIP (which is used to generate the python bindings for the c++ code in qt). Get them here: http://www.riverbankcomputing.com/software/sip/download and http://www.riverbankcomputing.com/software/pyqt/download . I created a folder pyqtstuff to put the source tarballs in. Extract them both and you should have two folders for each of the tarballs.
You need to compile SIP first. Now Mac OSX has python 2.6 already installed, if you want to use python 3 you need to install that. Whatever version of python you want to use pyqt4 with, you NEED to run the following scripts with the version of python you want to use. So if you want to use 2.6, you just use ‘python configure.py’, if python 3, then ‘python3 configure.py .
So, change directories to the sp folder and then run these commands.
sudo make install
If all goes well, then it wont report any errors.
Now you change directories to the pyqt folder, and do the same thing, making sure to run the configure.py script as the version of python you are going to use with pyqt. BUT , i had a problem where it was saying that ‘qmake’ was not in my path. Never fear, thats why you downloaded the QT SDK. You need to locate the folder where you installed it, and deep inside it is the qmake binary. I installed the sdk to the QtSDK folder, and my qmake was in :
The version number will probably differ, but other then that the path is the same. Now, make sure you copy the FULL PATH (from root, so for me it would be /Users/<username>/Programs/QtSDK/Desktop/Qt/473/gcc/bin/qmake , but substitute this with your own) and you need to pass it as an argument to the configure.py call. Again run this with the version of python you intend to use!
python configure.py -g -q <PATH TO QMAKE HERE>
That will configure pyqt. We use the -g because that ‘consolidates’ everything, which i’m not sure what that means, but the other option it told me to use did not work.
Now you just compile it and install it. This will probably take a bit of time since its kinda big. Be patient
sudo make install
Done! now you should be able to use PyQt4 on your mac. Hopefully this helps someone since I did not find a guide for it online yet. Post here if you have any questions!