Install PyQt6 on Ubuntu Linux

Install PyQt6 on Ubuntu and other Debian-based Linux distributions
Heads up! You've already completed this tutorial.

Before you start creating GUI applications with PyQt6, you need to have a working installation of PyQt6 on your system. In this short tutorial, you'll find the steps that will guide you through installing PyQt6 on Ubuntu Linux.

This guide is also available for macOS and Windows.

Note that the following instructions are for installing the PyQt6 version registered under the GPL license. If you need to use PyQt in a non-GPL project, then you will need to purchase an alternative license from Riverbank Computing to release your software.

Preparing Ubuntu to Install PyQt6

Before installing PyQt6, we need to prepare our operating system and install a couple of tools. Python best practices recommend using virtual environments to isolate our Python projects and manage their dependencies.

Unfortunately, the default Ubuntu installation doesn't include tools like the venv module, which allows us to create virtual environments, and the pip command, which lets us install external packages. So, we need to install them from the distro's repositories.

Installing the venv and pip

To install the venv module and the pip command in Ubuntu, we can run the following commands:

bash
$ sudo apt update
$ sudo apt install python3-venv python3-pip

The first command updates the package information from all sources of software we are using in our Ubutu system. The second command downloads and installs the venv module and the pip command. Now, we are ready to create and activate a Python virtual environment.

PyQt/PySide 1:1 Coaching with Martin Fitzpatrick — Get one on one help with your Python GUI projects. Working together with you I'll identify issues and suggest fixes, from bugs and usability to architecture and maintainability.

Book Now 60 mins ($195)

Creating a Virtual Environment

Once we've installed the venv module, we can proceed to create and activate a Python virtual environment:

bash
$ mkdir project/ && cd project/
$ python3 -m venv ./venv
$ source venv/bin/activate
(venv) $

First, we create a new working directory named project/ as a root for a hypothetical PyQt6 project. Then, we create a new virtual environment with venv and activate it. Note how the prompt indicator changes to signal that we're in an active virtual environment.

Install PyQt6 in a Virtual Environment With pip

Once we've created and activated our virtual environment, we can install PyQt6 with the following command:

bash
(venv) $ pip3 install pyqt6

This command downloads PyQt6 from the Python package index (PyPI) and installs it in our virtual environment.

Install PyQt6 System-wise Using apt

Sometimes, we may need to install PyQt6 in the operating system rather than in a virtual environment. In Ubuntu's repositories, we'll find packages for PyQt6, although they may be out of date. Check first to ensure you're getting a version that meets your requirements, and if not, use the pip method above.

Over 10,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]

In Ubuntu, we can install either from the command line with the apt command or via the Software Center. The package we are looking for is python3-pyqt6.

To install PyQt6 from the command line, execute the following command:

bash
$ sudo apt install python3-pyqt6

Check the Installation

After the PyQt6 installation is finished, we can start a Python interactive session and import the library as shown below to test your installation:

python
>>> import PyQt6

If you're using the pip installation, make sure you are in the terminal session with the active virtual environment. If you are using the apt installation, you can import the library from any terminal session.

Now that you've completed the installation in your Ubuntu Linux system, you can start creating Python GUI applications with PyQt6.

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Install PyQt6 on Ubuntu Linux was written by Martin Fitzpatrick with contributions from Lalin Paranawithana and Leo Well .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular https://www.martinfitzpatrick.com/browse/books/ on the subject.