Install PyQt5 on macOS
Install PyQt5 on macOS

Before you start the PyQt tutorial you will need to have a working installation of PyQt5 or PyQt6 on your system. If you don't have either set up yet, the following steps will guide you through how to do this on Windows.

This guide is also available for Windows and Linux.

Note that the following instructions are only for installation of the GPL licensed version of PyQt. If you need to use PyQt in a non-GPL project you will need to purchase an alternative license from Riverbank Computing to release your software.

Install PyQt5 on macOS

If you already have a working installation of Python 3 on macOS, you can go ahead and install PyQt5 as for any other Python package, using the following --

bash
pip3 install pyqt5

If you don't have an installation of Python 3, you will need to install one first. You can download macOS installers for Python 3 from the Python homepage. Once installed, you should be able to use the pip3 install command above to install PyQt5.

Another alternative is to use http://brew.sh/[Homebrew]. Homebrew is a package manager for command-line software on macOS. Homebrew has both Python 3 and PyQt5 available in their repositories.

Homebrew -- the missing package manager for macOS. Homebrew -- the missing package manager for macOS.

To install homebrew run the following from the command line --

bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This is also available to copy and paste from the Homebrew homepage.

Once Homebrew is installed you can then install Python with --

bash
brew install python3

With Python installed, you can then install PyQt5 as normal, using pip3 install pyqt5, or alternatively choose to install it using Homebrew with --

bash
brew install pyqt5

After install is finished, you should be able to run python (or python3) and import PyQt5 without errors.

python
Python 3.7.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
>>>

You can now start creating Python GUI applications with PyQt.

Install PyQt6 on macOS

If you already have a working installation of Python 3 on macOS, you can go ahead and install PyQt6 as for any other Python package, using the following --

bash
pip3 install pyqt6

If you don't have an installation of Python 3, you will need to install one first. You can download macOS installers for Python 3 from the Python homepage. Once installed, you should be able to use the pip3 install command above to install PyQt6.

Another alternative is to use Homebrew. Homebrew is a package manager for command-line software on macOS. Homebrew has both Python 3 and PyQt6 available in their repositories.

Homebrew -- the missing package manager for macOS. Homebrew -- the missing package manager for macOS.

To install homebrew run the following from the command line --

bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This is also available to copy and paste from the Homebrew homepage.

Once Homebrew is installed you can then install Python with --

bash
brew install python3

With Python installed, you can then install PyQt6 as normal, using pip3 install pyqt6, or alternatively choose to install it using Homebrew with --

bash
brew install pyqt6

After install is finished, you should be able to run python (or python3) and import PyQt6 without errors.

python
Python 3.7.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt6
>>>

You can now start creating Python GUI applications with PyQt.

Continue reading