Skip to content

How to Install PyQt4 on Osx

Note : this is a tutorial on Mac OS X 10.6.4, with : PyQt-mac-gpl-snapshot-4.7.5-8a6793a155e0.tar.gz and with : sip-4.11-snapshot-052b642f04a8.tar.gz.
It should be the same on previous and next versions. ( if you have some bugs you may also contact me )

How to install PyQt4 ?

  1. Download the SIP package (snapshot for OS x )
  2. Download the PyQt package (snapshot for OS x)
  3. Download Qt
  4. Install Qt
  5. Install SIP
  6. Install PyQt
  7. and try !

Let’s download the Qt binary from the website : Download site (You may take the complete SDK)

Let’s download the SIP snapshot : Download site (for OS x)

Let’s download the PyQt snapshot : Download site (for OS x)

And now let’s install the first Qt binary, just follow and click on next until it as finished to install.

SIP :

SIP is the program that bind C++ with Python

let’s  go were you have downloaded the sip tar.gz and enter the folder

and we are gonna try to install it with the following lines :

– arch i386 is to specify that we want this architecture

then lets make it and install it with the following commands :

PyQt4:

Once installed let’s move back an go to the PyQt folder to configure it and install it with the following command :

and let’s try to configure it with the right things

then let’s make them with:

and now, everything should be Up and running.

 

In OS X Lion and with the new versions there is a thread on QT website https://bugreports.qt.nokia.com/browse/QTCREATORBUG-6222 which says that qmake-4.7 is hidden in /usr/bin. Could someone confirm that it works.

{ 28 } Comments

  1. QT98 | 8 May 2011 at 22 h 54 min | Permalink

    Thanks a lot. Finally working !!!

  2. Noktec | 12 May 2011 at 18 h 38 min | Permalink

    You’r welcome ;)

  3. me | 29 May 2011 at 12 h 59 min | Permalink

    Your list of commands were a HUGE timesaver and it all worked. THANKS!!!

  4. Noktec | 29 May 2011 at 17 h 46 min | Permalink

    Thanks man ;)

  5. Ecker | 24 July 2011 at 2 h 12 min | Permalink

    I get to the first “make” command.
    Which just returns “command not found”.

    If I skip it and continue all I get on the next step is “ImportError: No moudle named sipconfig”

    What did I miss? I tried, and tried again.

  6. Ecker | 24 July 2011 at 2 h 44 min | Permalink

    I found out that X Code have to be installed for the “Make” command to work.

  7. Noktec | 24 July 2011 at 14 h 33 min | Permalink

    Yes, Xcode needed to be installed ( in theory everything should work well, on Leopard or Snow Leopard but i didn’t tried yet on Lion)

  8. Guillermo | 31 July 2011 at 18 h 52 min | Permalink

    Muchas gracias! this worked wonders i got it with qmake 4.7 just fine.

  9. yui | 17 August 2011 at 9 h 50 min | Permalink

    Hi, I am installing PyQt4 into my MacBookPro (10.6, unibody, core 2 duo, 2009).
    After I launched “$ python configure.py –use-arch=x86_64″,
    It’s been already almost 3 hours..
    Do you think Is it normal it takes so long time??

  10. Noktec | 17 August 2011 at 10 h 59 min | Permalink

    Hi,

    Actually I just read that it could take around 3h to 3h30′
    so you should let it run :) and see later on, if it gives
    any error message.

  11. yui | 17 August 2011 at 15 h 25 min | Permalink

    Thanks a lot for your reply.
    unfortunately it had been running for 6 hours so I just did force quite :(

    Apart from that, in this website, we are supposed to use Python 2.6, aren’t we?
    I am using 2.7, not 2.6, so in that case should I simply put a command something like following??:
    python configure.py -d /Library/Python/2.7/site-packages –arch x86_64

    Sorry for such a very very stupid question.
    I am a beginner for Python (and even for general programming).
    (Now I am trying to build an environment “Spyder2″ for Python2.7 in my Mac.)

  12. SSF | 10 January 2012 at 18 h 05 min | Permalink

    It is not working on the lion, the path /usr/bin/qmake-4.6 is not created after installing the SIP.

  13. Noktec | 13 January 2012 at 3 h 20 min | Permalink

    Dear SSF for your problem, I found a solution -> https://bugreports.qt.nokia.com/browse/QTCREATORBUG-6222

    tell me if this helped

  14. Jason Viloria | 16 January 2012 at 0 h 01 min | Permalink

    I needed to work with python2.7 due to collaboration with other people working on linux using python2.7 and this is what I did.

    1. Install macports and installed python2-7
    2. downloaded and installed the latest QT SDK. it installed it in QtSDK in my home folder /Users/jnvilo/QtSDK
    3. I downloaded the latest SIP version from the site provided and simply did /opt/local/bin/python2.7 configure.py; make ; make install
    4. When i tried to do the same with PyQt it complained about qt being static and I had to run the following command instead:

    python configure.py -q /Users/jnvilo/QtSDK/Desktop/Qt/474/gcc/bin/qmake -g

    I hope this helps
    /jnvilo

  15. Jason Viloria | 16 January 2012 at 0 h 02 min | Permalink

    Oh and last command should be:

    /opt/local/bin/python2.7 configure.py -q /Users/jnvilo/QtSDK/Desktop/Qt/474/gcc/bin/qmake -g

  16. Noktec | 16 January 2012 at 1 h 11 min | Permalink

    Thanks for the tips Jason !

  17. chair rail | 20 January 2012 at 20 h 02 min | Permalink

    I don’t know why…

  18. CMon | 25 April 2012 at 13 h 46 min | Permalink

    I have installed sip-4.13.2 on python 2.7 (on my Mac OSX 10.7.3 Lion). I don’t have errors when I do $ python and then >>import sip or >>import sipconfig.

    I have installed qt-mac-opensource-4.8.1.dmg and QtSdk-online-mac-x86-v1.2.1.dmg, but when I enter :
    $python configure.py -q /usr/bin/qmake-4.8 -d /Library/Python/2.7/site-packages/ –use-arch i386
    I have this error message that I cannot solve by myself :
    Determining the layout of your Qt installation…
    Error: Failed to determine the layout of your Qt installation. Try again using
    the –verbose flag to see more detail about the problem.
    How to solve this ? Or how to have more informations on this problem ?

  19. Noktec | 25 April 2012 at 13 h 55 min | Permalink

    Using the full QT path. I just saw that example

    “python configure.py -q /home/mahmoud/qtsdk-2009.05/qt/bin/qmake”

    So, try the full path to qmake.

    See this : http://ubuntuforums.org/archive/index.php/t-1427945.html

  20. CMon | 25 April 2012 at 14 h 14 min | Permalink

    Well in the QtDSK installation I don’t have /qt/bin/qmake things but I have in the qmake command in /usr/bin/qmake (and also a qmake-4.8)…

  21. Noktec | 25 April 2012 at 14 h 34 min | Permalink

    Btw Have you looked at this http://www.noktec.be/python/how-to-install-pyqt4-on-osx#comment-690 ?
    look at the path used.

  22. CMon | 25 April 2012 at 16 h 23 min | Permalink

    No changes with :
    $python configure.py -q /Users/labo/Documents/QtSDK/Desktop/Qt/4.8.1/gcc/bin/qmake -d /Library/Python/2.7/site-packages/ –use-arch i386 –verbose

  23. Noktec | 26 April 2012 at 13 h 40 min | Permalink

    I’m sorry I have no more ideas, but if you find the answer could you please tell me so I’ll be able to help similar problems in the future.

  24. AbiusX | 8 July 2012 at 3 h 27 min | Permalink

    You don’t need to go through all the hassle, the PyQtX binaries now provide you everything ready to use!

  25. Noktec | 8 July 2012 at 12 h 18 min | Permalink

    Hey AbiusX,

    I haven’t used PyQTX yet, but I’ll give it a try, and then I’ll edit my post following your comment.

    Btw thank you for the head up.

  26. Michael | 13 August 2012 at 20 h 25 min | Permalink

    if you get this error msg:
    configure.py: error: ‘/usr/bin/qmake-4.6′ is not a file

    check if this file exists in /usr/bin.
    if it doesn’t, install Qt libraries from:
    http://qt.nokia.com/downloads

  27. Juan | 28 February 2013 at 22 h 57 min | Permalink

    Hi, I’ve followed your instructions to the letter, but I still can’t install PyQt for Mountain Lion. The only way I can get something done is this:

    1. Download and Install Qt 5.0.1 (installs in local directory)

    2. Compile Sip 4.14 (all good here)

    3. Compile PyQt 4.9.6 with flag -q /Users/Juan/Qt5.0.1/clang_64/bin/qmake (there is no qmake in /usr/bin and /usr/local/bin or /usr/local/Cellar/qt/4.8.4/bin/ throws the following error:

    Determining the layout of your Qt installation…
    Error: Failed to determine the layout of your Qt installation. Try again using
    the –verbose flag to see more detail about the problem.

    4. Last step: make, but it does not go all the way through, it stops and throws the following error:

    /Users/Juan/Downloads/PyQt-mac-gpl-4.9.6/sip/QtCore/qstring.sip:205:35: error:
    use of undeclared identifier ‘TRUE’
    static bool check_codec = TRUE;
    ^
    /Users/Juan/Downloads/PyQt-mac-gpl-4.9.6/sip/QtCore/qstring.sip:213:27: error:
    use of undeclared identifier ‘FALSE’
    check_codec = FALSE;
    ^
    2 errors generated.
    make[1]: *** [sipQtCoreQString_0.o] Error 1
    make: *** [all] Error 2

    Any ideas? Help is appreciated!

    PS: I also tried with home-brew… but did not work neither.

  28. Noktec | 28 February 2013 at 23 h 12 min | Permalink

    Hi,

    I’ll try to install it on my Mac tonight or tomorrow, I let you (in the comments) know if I encounter the same problems and if I found any solutions.

{ 2 } Trackbacks

  1. [...] 1-3 were adapted from here. Step 4 was adapted from here. Share this:TwitterFacebookLike this:LikeBe the first to like this [...]

  2. A Qt GUI for Python scripts « Thesis Journal | 29 August 2012 at 4 h 23 min | Permalink

    [...] To install PyQt on my system (OS X 10.6.8), with Xcode installed, download and install SIP and PyQt4 following these directions here. [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *