I'm trying to do this on a raspberry pi 5
That would be Armbian (rebadged as "Raspberry Pi OS", because Broadcom and the Foundation abhor anything to do with GPL).
As it is a Debian derivative, just like Ubuntu and Mint and many others, these packages (Python, Qt, PySide2, PyQt5) are centrally managed as Debian packages.
Since you want to use graphical applications over an SSH connection, you need to have X11 client libraries on the Raspberry:
sudo apt install libx11-6(X11 client is the application; server is the one displaying things.)
You'll want to have
python3, and
pyside2 and/or
pyqt5 installed, letting them pull in all dependencies:
sudo apt install python3 sudo apt install python3-pyqt5 sudo apt install python3-pyside2.{qtcore,qtgui,qtsvg,qtuitools,qtwidgets}Next, there are two different scenarios: a display connected to the Raspberry Pi that you want to use, or running the application on the Raspberry but showing the windows on your desktop machine.
In the former case, you'll need to start a graphical
session on the Raspberry Pi, then "connect" to that session when you use SSH (typically by setting the
DISPLAY environment variable, say by running
export DISPLAY=:0). The exact details vary depending on whether you want a full desktop session, autologin session, a simplified session with just a window manager but no other applications, a plain X11 server, or just run a single full-screen Qt application.
In the latter case, showing the actual windows on your desktop machine (but controlled by the code running on the Raspberry Pi):
In your SSH program, you need to enable X11 forwarding, so that the application running on the Raspberry can show its windows and widgets in your Windows machine. In PuTTY, it's under Connection > SSH > X11. For command-line ssh clients, use
-Y or
-X command-line option, noting the letter is in uppercase.
Before you open the SSH connection, your workstation needs to have an X11 server running. WSL2 includes one, or you can use
MobaXterm (for both SSH and X11 server), or
Xming.
If you choose to use WSL2, then you can run the above
apt commands to install Python 3, Qt 5, and PyQt5/PySide2 bindings to WSL2, so you can directly run Python3+Qt5 code in WSL2. I don't have Windows myself, but as I understand it, that should work really well too.