How to get the PyQt version number?
Find out which version of PyQt or PySide you're running

Heads up! You've already completed this tutorial.

Sometimes you need to know which version of PyQt or PySide you have installed. Below are two methods of getting this information from your system -- first using pip and second from PyQt/PySide itself.

Finding the version from the command prompt

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.

bash
pip show pyqt5
bash
pip show pyqt6
bash
pip show pyside2
bash
pip show pyside6

This outputs the metadata from the pip database, including the version number, e.g.

python
Name: PyQt5
Version: 5.15.1
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: /home/martin/.local/lib/python3.7/site-packages
Requires: PyQt5-sip
Required-by:

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 PyQt which are only available in specific versions and you want to disable this in earlier versions.

In that case you can use the following code to get the version number. This also gives you the version of Qt.

python
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)
python
from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)
python
import PySide2
import PySide2.QtCore
print("Qt: v", PySide2.QtCore.__version__, "\tPyQt: v", PySide2.__version__)
python
import PySide6
import PySide6.QtCore
print("Qt: v", PySide6.QtCore.__version__, "\tPyQt: v", PySide6.__version__)

You can run this by opening up a Python shell and copy-pasting in the above code. On my machine it produces the following output.

python
>>> 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
python
>> from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
>>> print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)
Qt: v 6.2.0     PyQt: v 6.2.0
python
>>> import PySide2
>>> import PySide2.QtCore
>>> print("Qt: v", PySide2.QtCore.__version__, "\tPyQt: v", PySide2.__version__)
Qt: v 5.15.2    PyQt: v 5.15.2
python
>>> import PySide6
>>> import PySide6.QtCore
>>> print("Qt: v", PySide6.QtCore.__version__, "\tPyQt: v", PySide6.__version__)
Qt: v 6.2.0     PyQt: v 6.2.0
The complete guide to packaging Python GUI applications with PyInstaller.
[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

How to get the PyQt version number? was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.