Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BennyE/e19b905b1da40d4e1874 to your computer and use it in GitHub Desktop.
Save BennyE/e19b905b1da40d4e1874 to your computer and use it in GitHub Desktop.
Howto set up a PyQt 5 environment on MacOS X Yosemite (10.10.3) for Python 3
This short article aims to give you the instructions on how to set up a PyQt 5.4.1 environment on a Mac with Yosemite 10.10.3 for Python 3.
Prerequisites:
- XCode downloaded and installed along with the command-line utilities (you need that to compile PyQt & SIP)
- Python3 downloaded and installed (I'm using Python v3.4.3)
- Download Qt 5.4.1 for Mac (598 MB)
-> http://www.qt.io/download-open-source/#section-2
(Should be named something like "qt-opensource-mac-x64-clang-5.4.1.dmg")
- Download SIP Source (sip-4.16.7.tar.gz)
-> http://www.riverbankcomputing.com/software/sip/download
- Download PyQt Source (PyQt-gpl-5.4.1.tar.gz)
-> http://www.riverbankcomputing.com/software/pyqt/download5
Install "Qt 5.4.1", this is GUI-driven and shouldn't be an issue for anyone.
Navigate to the directory where you installed "Qt 5.4.1" and "qmake", in my case that is "/Users/BennyE/Qt5.4.1/5.4/clang_64/bin/qmake"
(Take a note of that full path, you'll need it in a few.)
Configure, compile & Install SIP
(I assume you know how to unpack a tar.gz and omit that details.)
$ cd sip-4.16.7
IMPORTANT: If you want to build this whole thing for Python3, it is very important to do the "configure.py" step with your Python3 binary!
$ python3 configure.py
$ make
$ make install
You can easily test if that worked by doing the following:
$ python3
>>> import sip
>>> sip.SIP_VERSION_STR
'4.16.7'
>>> exit()
Configure, compile & Install PyQt v5.4.1
IMPORTANT:
- You need to adapt the path to "qmake" to your local environment!
- Please don't forget to run Python3 for the configure.py!
$ cd PyQt-gpl-5.4.1
$ python3 configure.py --qmake /Users/BennyE/Qt5.4.1/5.4/clang_64/bin/qmake
$ make
$ make install
To test your newly installed Qt/PyQt, you can do the following:
$ python3
>>> from PyQt5.QtGui import *
>>> import sys
>>> a = QGuiApplication(sys.argv)
>>> w = QWindow()
>>> w.setTitle("Hello World!")
>>> w.show()
I hope this worked for you! :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment