Last modified: Mar 25, 2025 By Alexander Williams

How to Install PyQt in Python Step by Step

PyQt is a popular library for creating GUI applications in Python. It combines Python with Qt, a powerful framework for building interfaces. This guide will help you install PyQt easily.

Prerequisites

Before installing PyQt, ensure you have Python installed on your system. You can check this by running python --version in your terminal.


python --version


Python 3.9.7

If Python is not installed, download it from the official website. Also, ensure pip is available. Pip is Python's package manager.

Install PyQt Using Pip

The easiest way to install PyQt is using pip. Open your terminal or command prompt and run the following command.


pip install PyQt6

This will install the latest version of PyQt. If you need a specific version, specify it like this.


pip install PyQt6==6.2.0

Verify the Installation

After installation, verify PyQt is installed correctly. Run the following Python code.


import PyQt6.QtWidgets
print("PyQt6 installed successfully!")


PyQt6 installed successfully!

If you see an error like ModuleNotFoundError, check our guide on how to solve ModuleNotFoundError.

Install PyQt Tools

PyQt comes with useful tools like Qt Designer. Install them using pip.


pip install PyQt6-tools

These tools help design GUIs visually. They are optional but recommended for beginners.

Create a Simple PyQt Application

Test your installation by creating a simple window. Copy the code below.


from PyQt6.QtWidgets import QApplication, QLabel, QWidget

app = QApplication([])
window = QWidget()
window.setWindowTitle("PyQt Test")
window.setGeometry(100, 100, 300, 200)

label = QLabel("Hello, PyQt6!", parent=window)
label.move(100, 80)

window.show()
app.exec()

Run the script. A small window with a label should appear. This confirms PyQt is working.

Common Installation Issues

Sometimes, installation fails due to missing dependencies. Ensure your system meets all requirements.

If you encounter permission errors, try adding --user to the pip command.


pip install --user PyQt6

For other issues, check the official PyQt documentation or community forums.

Conclusion

Installing PyQt in Python is simple with pip. Follow the steps above to set it up quickly. Now you can start building GUI applications.

If you face any errors, refer to our guide on solving ModuleNotFoundError. Happy coding!