How to install PyQt
Tags: python, pyqt
Published: 2019-10-29 14:53:54

---
title: How to install PyQt
cover_image: https://cdn.pixabay.com/photo/2019/10/26/11/38/hallstatt-4579234_960_720.jpg
tags: python, pyqt
published: true
---
<a href="https://riverbankcomputing.com/software/pyqt/intro/">PyQt</a> is excellent for using for Python interfaces, as it is flexible, and allows you access to a wide array of functionalities. 

But to get access to all its advantages, you must first install it correctly. Thus, let’s see down below how to install PyQt and get the best programming functionalities from this framework.
 
PyQt is a GUI framework for Python, it requires <a href="https://pythonbasics.org">basic Python</a> knowledge.

## 1 Setup

First of all, you will have to install Python, depending on your operating system. You can opt from distinct software, but the most popular ones are Windows and Linux. 

Qt in Python comes in a package named PyQt. PyQt includes everything you need to start using GUIs in Qt Designer via Python. 

On Linux (Ubuntu)

    sudo apt-get install qtcreator pyqt5-dev-tools
    sudo apt-get install python3-pyqt5
    sudo apt-get install qttools5-dev-tools

For other platforms, use the website. You can download PyQt from <a href="https://www.qt.io/download">their official page</a> and opt for the Qt Designer package, too. Depending on your options, you will have to complete the installation process, as mentioned in the PyQt website.
 
<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.seppemagiels.com%2Fsites%2Fdefault%2Ffiles%2Fimages%2Finstall-qt.png&f=1&nofb=1">

## 2 Check the PyQt package you installed
As soon as the installation process is finished, you should be able to identify inside Python’s directory a folder named PyQt. 

Here, you will discover library files for Python, along with executables and scripts. 

The next step is to verify if Python has access to the PyQt package, and you can do so by opening a line in your command terminal. 

    $ python3
    import PyQt5

You can also try a <a href="https://pythonprogramminglanguage.com/pyqt5-hello-world/">hello world script</a> to see if PyQt works correctly.

## 3 Starting GUI in Python with PyQt

At this point, you will have to create a <a href="https://pythonspot.com/gui/">GUI</a> and load it into Python (with <a href="https://pythonbasics.org/qt-designer-python/">designer</a>). 

    /usr/bin/designer

After this, you will have to convert via PyQt, code in Python, and execute accordingly. 
 
## 4 Creating custom settings to GUI events

After creating the interface, you will have to create a building software, or a part bridging GUI to the business approach. 

Thus, you will need to design a Python script accordingly to the features you will want to have included in your finite product. 

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3oKIPnAiaMCws8nOsE%2Fgiphy.gif&f=1&nofb=1">
 
## 5 Setting up your GUI in Qt Designer

When you access Qt Designer, you should receive a dialog box prompting you to open a New Form. Opt for Dialog with Bottom or the default option and press the create button. 
 
<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcdncontribute.geeksforgeeks.org%2Fwp-content%2Fuploads%2FPyQt_new_window.png&f=1&nofb=1">

## 6 Creating buttons or widgets

In the Qt Designer window, you will find a setting named Widget Box. You can drag from there any type of widget you desire and adapt them depending on your project. 

Keep in mind that the default functionality comes with two necessary <a href="https://pythonpyqt.com/pyqt-button/">buttons</a>, OK and Cancel. Those can be modified by clicking on them and changing their settings in the Property Editor.
 
From this point on, you can mix and match a wide array of functionality related to Python and PyQt. It is a versatile method of coding, as it allows you to use several characteristics available with this framework. 

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.stack.imgur.com%2F79FdX.png&f=1&nofb=1" alt="qt designer">

You can use this cross-platform on Windows by installing Python, and adding all the PyQt extras. For this software, it is not required to compile everything. 

For Mac OS, you will need the Mac OS X binary, which will allow you to install PyQt on your terminal. 

For Linux, you will discover that Python is installed by default. Therefore, you will only need to install PyQt software, package manager.

 
**Resources**
* <a href="https://gum.co/pysqtsamples">Course on PyQt Desktop Apps</a>
* <a href="https://pythonbasics.org/pyqt-hello-world/">PyQt programming tutorial</a>
* <a href="https://riverbankcomputing.com/software/pyqt/intro/">PyQt module site</a>