Sometimes you need to know which version of PyQt5 you have installed. Below are two ways of getting this information from your system -- first using the pip
command and second, from PyQt5 itself.
Finding the Version From the Command Line
If you just want to know which version is installed for yourself, 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 on this output shows the PyQt5 version number you're using in your current Python environment. In this particular example, we're using PyQt5 version 5.15.9.
Finding the Version Within Your Code
Sometimes, you need to know the version within your code. Perhaps you're a library developer, and your 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 version number.
>>> from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
>>> print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)
Qt: v 5.15.2 PyQt: v 5.15.6
This also gives you the version of Qt. In my machine, I'm running Qt version 5.15.2 and PyQt5 version 5.15.6.
PyQt/PySide 1:1 Coaching with Martin Fitzpatrick — Save yourself time and frustration. 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.