How to use pyside2 from the Ubuntu repository to develop programs?

When I run apt search pyside packages I get for example:

python3-pyside2.qtwidgets/focal 5.15.2-1+20.04+focal+release+build1 amd64

When I install it, how can I use it with my python-programm? Do I need to package my python-programm as .deb? How does it work and what do I need to consider?


Installing python3-pyside2.qtwidgets alone may not be enough. Install all the following packages instead.

sudo apt install python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qtwidgets python3-pyside2.qtnetwork

When I install it, how can I use it with my python-programm?

You just need to import appropriate libraries. Example:

from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
    QRect, QSize, QUrl, Qt)

Do I need to package my python-programm as .deb?

If you want to use it yourself, then no.

If you want to distribute it, then you can either upload to PyPI and ask people to install from pip, or package it as .deb and distribute (alternatively, if the program is simple enough, just distribute the source, and ask users to install PySide2 manually).