How can I get to work PyQt 4 or 5 on a Mac with OS X Sierra? It seems that I have to wait for a new version of PyQt but I am not sure if that is actually true.
-
Did you try compiling PyQt yourself? – Daniele Pantaleone Oct 03 '16 at 07:15
6 Answers
Make sure you have homebrew installed.
Use the following commands:
brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt
brew install pyside

- 11,045
- 8
- 74
- 149

- 317
- 3
- 5
-
I've never seen the "tap" commands in other installation "guides" before. They seem to make all the (necessary!) difference. – Thomas Tempelmann Mar 16 '17 at 09:05
-
I needed to run `pyuic4`, which wasn't available after these commands. I then also ran `brew install sip pyqt`, and after that it worked, though I also had to follow some instructions to fix a few issues, including creating the *site-packages* import. – Thomas Tempelmann Mar 16 '17 at 09:29
-
2brew install qt wanted to install 5.9.0 for me, so I did `brew install cartr/qt4/qt` instead. – SpinUp __ A Davis Jun 05 '17 at 20:25
-
4And similarly, if you want, PyQt4, you can do `brew install cartr/qt4/pyqt`. – SpinUp __ A Davis Jun 05 '17 at 20:47
-
5
Considering PyQt4 is no longer actively supported by its creators, I'd recommend using PyQt5 (plus I found it much easier to get working). Once you've installed pip3
(you can use easy_install
) run the following commands in your terminal:
1) pip3 install sip
2) pip3 install PyQt5
You can then run the following sample app to see if everything is working:
import sys
from PyQt5 import QtWidgets
def main():
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
button = QtWidgets.QPushButton("Hello, PyQt!")
window.setCentralWidget(button)
window.show()
app.exec_()
if __name__ == '__main__':
main()

- 1,176
- 19
- 22
-
1This solution worked great for me, couldn't find a cartr PyQt5 version (approach referenced in the top solution) – Mark Essel Apr 21 '20 at 16:01
The easiest way to install PyQt (4 or 5) on OSX is probably using Homebrew. This will also install a separate standalone Python from the system Python, meaning it will continue to work without problems following any future system updates.
According to this thread PyQt4 is no longer supported on macOS Sierra, but PyQt5 will still work.
Once you've installed Homebrew, you can install PyQt5 with the following:
brew install pyqt5 # for PyQt5

- 15,275
- 7
- 50
- 70
-
10@Parsa it is what I used to install it on my own laptop with macOS Sierra. Sorry it doesn't work for you, but no need for the snark. Post your own solution if you have one. – mfitzp Oct 14 '16 at 07:05
I managed to get Qt5 with PyQt5 installed (on both 10.10.5 and 10.12) using these steps, which I learned from https://gist.github.com/guillaumevincent/10983814:
- Install Xcode (required by Qt5 installer)
- Install Python 3 from https://www.python.org/downloads/ (includes
pip3
command) - Install Qt5 from https://www.qt.io/
- Install SIP (
pip3 install SIP
) - Install PyQt (
pip3 install PyQt5
)
This also made commands such as pyuic5
available in Terminal.app (requires re-opening the Terminal window once to recognize the new search paths).

- 11,045
- 8
- 74
- 149
If you still get the import error, you should also add
PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/site-packages/"
export PYTHONPATH
to your ~/.bash_profile
file after you applied the above stated steps, then it should work fine (make sure that PyQt4 is installed in that folder). I have installed python with conda and this import error seems to be related to anaconda.

- 1,349
- 2
- 11
- 17

- 11
- 1
1:
brew install cartr/qt4/pyqt
brew link qt@4
2: go here and download https://riverbankcomputing.com/software/sip/download
and do
tar -xzvf sip-4.19.6.tar.gz
cd sip-4.19.6
python configure.py
make
make install
3: go here and download : https://riverbankcomputing.com/software/pyqt/download
and do
tar -xzvf PyQt4_gpl_mac-4.12.1.tar.gz
cd PyQt4_gpl_mac-4.12.1
python configure.py
make
make install
4: test in python:
import sys;
from PyQt4 import QtGui;
def pyqtDemo():
app = QtGui.QApplication(sys.argv);
w = QtGui.QWidget();
w.resize(250, 150);
w.move(300, 300);
w.setWindowTitle('Hello World');
w.show();
sys.exit(app.exec_());
pyqtDemo()