Sometimes you need to know which version of PyQt6 you have installed. Below are two ways of getting this information from your system -- first using the pip command and second, from PyQt6 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 pyqt6
Name: PyQt6
Version: 6.9.0
Summary: Python bindings for the Qt cross platform application toolkit
Home-page: https://www.riverbankcomputing.com/software/pyqt/
Author:
Author-email: Riverbank Computing Limited <info@riverbankcomputing.com>
License: GPL v3
Location: .../lib/python3.13/site-packages
Requires: PyQt6-Qt6, PyQt6-sip
Required-by:
The second line on this output shows the PyQt6 version number you're using in your current Python environment. In this particular example, we're using PyQt6 version 6.9.0.
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 PyQt6 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 PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
>>> print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)
Qt: v 6.9.0 PyQt: v 6.9.0
This also gives you the version of Qt. In my machine, I'm running version 6.9.0 of both Qt and PyQt6.
Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!