Last Update Aug/13/2012: check out PyQtX , nice and easy one stop installation app. Thanks AbiusX !
I’ve been searching for the ways to successfully install PyQt4 on my macbook pro with Lion 10.7.2
After a long hard test, here comes my final step:
1) Download All the Required Software:
* Qt 4.7.4 Library:
2) Install Qt 4.7
This will be pretty straightforward. Double click it and install it like normal dmg file. It will be installed under /Developer/Applications/Qt
3) Install SIP
- Unzip SIP 4.13, and from terminal, cd into the folder like:
- Then type:
After that, it will install to your current version of python. ( in my mac, I only have 2.7)
If you want to specify which python to use, you can type:
python configure.py -d /Library/Python/2.7/site-packages --arch x86_64
- Make and install it:
sudo make install
4) Change some code in Qt
Because Qt 4.7 is not officially support Lion, you might get error like “This version of Mac OS X is unsupported”, but actually, if you are not going to use some of the features in Lion, Qt will work pretty well. So, in order to get rigid of this annoying error, you need to do some changes to the header file named: qglobal.h, which lies in /Library/Frameworks/QtCore.framework/Versions/4/Headers.
open this file by using any editor, like vim.
find the line:
# if !defined(MAC_OS_X_VERSION_10_6) # define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1 # endif
# if !defined(MAC_OS_X_VERSION_10_7) # define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1 # endif
if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6)
if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_7)
Save and close the file.
4) Install PyQt
- Unzip PyQt into a folder, and cd to that folder, like what we do for install SIP
- Inside PyQt’s folder, type
python configure.py -d /Library/Python/2.7/site-packages/ -g --use-arch x86_64
- After that, type
- It takes about 10 mins to finish, then type
If all turns out to be successful, you will a folder named PyQt4 under
To test if you can use it, in python prompt type
to see if it can be load