Search code examples
installationraspberry-pipysidepyside2raspberry-pi4

How do you install and use PySide2 on a Raspberry Pi 4?


I am trying to install PySide2 on my Raspberry Pi model 4.

I have attempted the following:

$ pip3 install pyside2

Result:

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyside2
  Could not find a version that satisfies the requirement pyside2 (from versions: )
No matching distribution found for pyside2

I then tried an approach I saw in a different thread:

sudo apt-get install python3-pyside2.qt3dcore python3-pyside2.qt3dinput python3-pyside2.qt3dlogic python3-pyside2.qt3drender python3-pyside2.qtcharts python3-pyside2.qtconcurrent python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qthelp python3-pyside2.qtlocation python3-pyside2.qtmultimedia python3-pyside2.qtmultimediawidgets python3-pyside2.qtnetwork python3-pyside2.qtopengl python3-pyside2.qtpositioning python3-pyside2.qtprintsupport python3-pyside2.qtqml python3-pyside2.qtquick python3-pyside2.qtquickwidgets python3-pyside2.qtscript python3-pyside2.qtscripttools python3-pyside2.qtsensors python3-pyside2.qtsql python3-pyside2.qtsvg python3-pyside2.qttest python3-pyside2.qttexttospeech python3-pyside2.qtuitools python3-pyside2.qtwebchannel python3-pyside2.qtwebsockets python3-pyside2.qtwidgets python3-pyside2.qtx11extras python3-pyside2.qtxml python3-pyside2.qtxmlpatterns python3-pyside2uic

This appeared to successfully install PySide2. re-entering this command confirms that these modules are already "the newest version". However, I could not find it in my list of installed packages using:

$ pip3 list

The package is also not recognized by python when I attempt to import the library. Does anyone have a working fix for this?


Solution

  • I've discovered that my Python 3 dist-packages directory was not added to PATH. To fix this, I entered the following commands into the Terminal:

    PYTHONPATH="/usr/local/lib/python2.6/site-packages/":"${PYTHONPATH}"
    export PYTHONPATH
    

    I also added the following path just in case (I am quite new to this):

    export PATH=$PATH:/usr/local/lib/python3.7/dist-packages/site.py
    

    After that,

    import PySide2
    

    became functional.