How to install PyQt5 in Ubuntu Linux?

Qt is a framework for the graphical user interface which is used for developing cross-platform applications. It makes it easy to develop applications with native-looking GUIs by using standard C++ that’s why it is classified as a widget toolkit.

PyQt is a comprehensive set of Python bindings for Qt which makes python to be used as an alternative application development language to c++ on all supported mobile and desktop platforms. It can also be used with applications developed in C++ to configure or enhance the functionalities.

In this article, I will discuss how to install PyQt5 on a Ubuntu system.

Prerequisites

To follow this guide you should have access to a user account on a Ubuntu system with superuser privileges.

How to install PyQt5 on Ubuntu

There are multiple ways in which you can install the PyQt5 package on Ubuntu. Now use one of the given methods to install it on your system.

Installing PyQt5 from Ubuntu repository

PyQt5 package is available in the official repository of Ubuntu we can directly use the apt command to install it –

But before installing a package on your system make sure the apt package repository is updated –

sudo apt update

Now use the following command to install PyQt5 on a Ubuntu system –

sudo apt install python3-pyqt5

Installing PyQt5 using pip

You can also use pip or package installer for Python to install PyQt5 on your system. For this, you should have Python 3.6 or higher installed on your system.

You can install Python3 by using –

sudo apt install python3 -y

Now use the following command to install PyQt5 using pip –

pip3 install PyQt5

Press y and then enter if it ask for your confirmation.

How to use PyQt5 in Ubuntu

Once the package gets installed you can directly import it into your program and start building GUI applications.

You can import this package as given in the image below.

pyqt5

To know the detailed usage of PyQt5 for building applications you can follow its official reference guide.

How to remove PyQt5 from Ubuntu

Now for any reason, if you want to remove PyQt5 from your Ubuntu system then use the following command in your terminal –

sudo apt remove python3-pyqt5 -y

OR use the following pip command to remove it –

pip3 uninstall PyQt5

Conclusion

Ok, so you have successfully installed the PyQt5 package on your system. Now if you have a query then write us in the comments below.

Leave a Comment