Installing PyQt4 On Mac OSX

This method has been verified to work on Macs running Mavericks, El Capitan, Sierra and High Sierra.

PyQt provides a great set of libraries for rendering user interfaces that are truly cross platform. Being able to distribute to both Mac and PC is great for situations where the workforce may have a combination of platforms. Plus being a Python library, you also have the ability to interact directly with various software interfaces, such as Maya, Max or MotionBuilder. Visit this link to see an example project that demonstrates a successful install (as of 01/05/2018 on High Sierra):


So how do you set it up? A straightforward operation, you might imagine. Just run:

pip install pyqt

Well that just won’t plug in any more. PyQt5 is the default install via pip nowadays, so many guides to installing PyQt4 that you’ll find on blogs don’t take that into account. The book that I started following, Rapid GUI Programming With Python And QT does feature instructions on how to install PyQt, and even they are out of date.

After running down many a cul-de-sac, I found one solid way of setting up PyQt4.

N.B. I got this method to work on Mavericks,  El Capitan, Sierra and High Sierra, so it should be pretty solid.

Installing Brew

If you haven’t already got Homebrew installed, you will need to have the command-line tools set up for XCode. Then you can install Homebrew

xcode-select --install
ruby -e "$(curl -fsSL"


Installing PyQt4

Now you can go ahead and install PyQt4. You need to specify an exact path because of the PyQt5 default issue:

brew install cartr/qt4/pyqt

Installing Python

Next, you need to create a clean install of Python 2.7 via Homebrew:

brew install python

Setting Up The Environment

PyQt is now installed, but you need to add the references to your Python environment. Brew has its installs in the folder, ‘/usr/local/Cellar’. Link your project to the Python executable in the cellar folder.

Wing IDE

My path was something like this:


Lastly, add the pyqt folder to your Python Path





In order to manage your environment in PyCharm, you need to follow the following steps:

  1. PyCharm > Preferences
  2. Set The Project Interpreter to the version of Python2.7 in the /usr/local/Cellar path, whatever the specific path may be.
  3. Click on the add module button to install the Qt module to the project. I had success in installing the PyQtX module. This can take a bit of experimentation to see what works…


You should now be able to get PyQt up and running in your IDE.

import sys
from PyQt4 import QtGui

def window():
   app = QtGui.QApplication(sys.argv)
   w = QtGui.QWidget()
   b = QtGui.QLabel(w)
   b.setText('Hello World!')
if __name__ == '__main__':




The landscape for getting Python Qt technology working is constantly changing, and all machines have their idiosyncratic foibles and gotchas, so follow the updates to see what might work if the above steps don’t get you there!

Edit 07/01/2018

While executing this stage on a new computer, I was required to do further operations in order to complete this task:

  1. Run: sudo xcodebuild -license
  2. Agree with the Xcode license requirements.
  3. Rerun the Ruby command once this was complete.

Edit 02/03/2018

Set up on another new Mac. I did not have to do the above step!

Edit 01/05/2018

I found a method for installing PySide.  A viable equivalent if PyQt4 is being dickie.

brew install qt

pip install -U PySide



9 thoughts on “Installing PyQt4 On Mac OSX

    • There isn’t necessarily an advantage. However, if you are working with software that requires PyQt4, such as Maya 2015, you may have no choice. As a Python UI developer, for the next few years, it may be important to be able to support development in both PyQt4 and PyQt5.


  1. Hi,
    I tried to install PyQt4 following your tuto but I don’t understand how you obtain the dialog box to add the pyqt folder to the Python Path. Thus when I open python and try to import PyQt4, it doesn’t find it.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s