Sometimes you need to know which version of PyQt5 you have installed. Below are two ways to check your PyQt5 version — first using the pip command from the command line, and second, programmatically from within your Python code.
Finding the PyQt5 Version from the Command Line
If you just want to quickly check which PyQt5 version is installed, and you installed the package using pip, you can use the following command to return the current version:
$ pip show pyqt5
Name: PyQt5
Version: 5.15.9
Summary: Python bindings for the Qt cross platform application toolkit
Home-page: https://www.riverbankcomputing.com/software/pyqt/
Author: Riverbank Computing Limited
Author-email: info@riverbankcomputing.com
License: GPL v3
Location: .../lib/python3.13/site-packages
Requires: PyQt5-sip
Required-by: PyQtWebEngine
The second line of this output shows the PyQt5 version number you're using in your current Python virtual environment. In this particular example, we're using PyQt5 version 5.15.9.
Finding the PyQt5 Version within Your Python Code
Sometimes, you need to check the PyQt5 version programmatically within your code. For example, you might be a library developer whose code uses certain features of PyQt5 that are only available in specific versions, and you want to disable these in earlier versions.
In that case, you can use the following code to get the PyQt5 version number along with the underlying Qt version.
>>> from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
>>> print(
"Qt: v", QT_VERSION_STR,
"\tPyQt5: v", PYQT_VERSION_STR
)
Qt: v 5.15.2 PyQt5: v 5.15.6
This also gives you the version of Qt. On my machine, I'm running Qt version 5.15.2 and PyQt5 version 5.15.6.
The QT_VERSION_STR constant returns the Qt version as a string, while PYQT_VERSION_STR returns the PyQt5 version. Both are imported from the PyQt5.QtCore module.
If you're working with PyQt6 or PySide6 instead, see our guides on getting the PyQt6 version number or getting the PySide6 version number.
Summary
To check your PyQt5 version, you have two straightforward options:
- From the command line: Run
pip show pyqt5to see the installed version and other package details. - From Python code: Import
QT_VERSION_STRandPYQT_VERSION_STRfromPyQt5.QtCoreto access both the Qt and PyQt5 version strings programmatically.
If you're unsure whether PyQt5 is the right choice for your project, take a look at our comparison of PyQt5 vs PyQt6 to understand the differences between the two versions.
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.