How to Get the PySide2 Version Number?

Find out which version of PySide2 you're running
Heads up! You've already completed this tutorial.

Sometimes you need to know which version of PySide2 you have installed. Below are two ways to check the PySide2 version number on your system -- first using the pip command on the command line, and second, programmatically from within your Python code.

If you haven't installed PySide2 yet, check out the installation guides for Windows, macOS, or Linux.

Check the PySide2 Version From the Command Line

If you just want to find out which PySide2 version is installed, and you installed the package using pip, you can use the pip show command to return the current version:

sh
$ pip show pyside2
Name: PySide2
Version: 5.15.8
Summary: Python bindings for the Qt cross-platform application and UI framework
Home-page: https://pyside.org
Author:
Author-email: Qt for Python Team <pyside@qt-project.org>
License: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
Location: .../lib/python3.13/site-packages
Requires: PySide2-Addons, PySide2-Essentials, shiboken2
Required-by:

The second line of this output shows the PySide2 version number you're using in your current Python environment. In this particular example, we're using PySide2 version 5.15.8.

Get the PySide2 Version Number in Python Code

Sometimes, you need to check the PySide2 version from within your Python code. For example, you might be a library developer whose code uses features of PySide2 that are only available in specific versions, and you want to disable these in earlier versions.

In that case, you can use the PySide2.__version__ attribute to get the version number programmatically.

python
>>> import PySide2
>>> import PySide2.QtCore
>>> print(
    "Qt: v", PySide2.QtCore.__version__,
     "\tPySide2: v", PySide2.__version__
)
Qt: v 5.15.8     PySide2: v 5.15.8

This also gives you the version of Qt via PySide2.QtCore.__version__. On my machine, I'm running version 5.15.8 of both Qt and PySide2.

Summary

To quickly check which PySide2 version you have installed:

  • From the command line: Run pip show pyside2 and look for the Version field.
  • From Python code: Use PySide2.__version__ for the PySide2 version or PySide2.QtCore.__version__ for the underlying Qt version.

If you're considering upgrading to PySide6, see our guide on the differences between PySide2 and PySide6 to understand what's changed.

Over 15,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Get the book

Downloadable ebook (PDF, ePub) & Complete Source code

[[ 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 ]]

Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PySide2 Edition) The hands-on guide to making apps with Python — Save time and build better with this book. Over 15K copies sold.

Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

How to Get the PySide2 Version Number? was written by Martin Fitzpatrick with contributions from Leo Well.

Martin Fitzpatrick is the creator of Python GUIs, and has been developing Python/Qt applications for the past 12+ years. He has written a number of popular Python books and provides Python software development & consulting for teams and startups.