PySide2 installation instructions should mention to also install Qt?


The book (appendix A) states to install PySide2 using pip3 (Windows and macOS) or apt-get (Linux).

Supposedly, running pip3 install pyside2 only install the bindings to the library, does it not? Shouldn’t we also install Qt itself by downloading the installer from the Qt website? Or am I misunderstanding?

Using a package manager such as Homebrew (macOS) or apt-get (Linux) supposedly takes care of this dependency, although see my other post about the apt-get command sadly not being functional.

Hi @nael

You don’t actually need a separate installation of Qt. When you install PyQt5/PySide2 the binary libraries are installed alongside the Python code. See below for example of PySide2 install folder on Windows, the .dll files are the Qt5 libraries.

 Directory of C:\Users\Gebruiker\AppData\Local\Programs\Python\Python37\Lib\site-packages\PySide2

28/01/2020  13:51    <DIR>          .
28/01/2020  13:51    <DIR>          ..
28/01/2020  13:51         4,173,928 d3dcompiler_47.dll
28/01/2020  13:51           589,432 designer.exe
28/01/2020  13:51    <DIR>          examples
28/01/2020  13:51    <DIR>          glue
28/01/2020  13:51    <DIR>          include
28/01/2020  13:51           207,992 lconvert.exe
28/01/2020  13:51            23,672 libEGL.dll
28/01/2020  13:51         3,573,880 libGLESv2.dll
28/01/2020  13:51         1,326,200 linguist.exe
28/01/2020  13:51           219,256 lrelease.exe
28/01/2020  13:51           567,416 lupdate.exe
28/01/2020  13:51        20,923,392 opengl32sw.dll
28/01/2020  13:51    <DIR>          plugins
28/01/2020  13:51           134,144 pyside2-lupdate.exe
28/01/2020  13:51           144,896 pyside2.abi3.dll
28/01/2020  13:51            44,812 pyside2.abi3.lib
28/01/2020  13:51    <DIR>          qml
28/01/2020  13:51                21 qt.conf
28/01/2020  13:51           235,008 Qt3DAnimation.pyd
28/01/2020  13:51            18,524 Qt3DAnimation.pyi
28/01/2020  13:51           261,120 Qt3DCore.pyd
28/01/2020  13:51            22,114 Qt3DCore.pyi
28/01/2020  13:51           465,408 Qt3DExtras.pyd
28/01/2020  13:51            34,759 Qt3DExtras.pyi
28/01/2020  13:51           225,792 Qt3DInput.pyd
28/01/2020  13:51            17,554 Qt3DInput.pyi
28/01/2020  13:51            52,224 Qt3DLogic.pyd
28/01/2020  13:51             2,867 Qt3DLogic.pyi
28/01/2020  13:51         1,107,456 Qt3DRender.pyd
28/01/2020  13:51           152,136 Qt3DRender.pyi
28/01/2020  13:51           419,960 Qt53DAnimation.dll
28/01/2020  13:51           383,608 Qt53DCore.dll
28/01/2020  13:51           628,344 Qt53DExtras.dll
28/01/2020  13:51           375,416 Qt53DInput.dll
28/01/2020  13:51            50,808 Qt53DLogic.dll
28/01/2020  13:51           172,664 Qt53DQuick.dll
28/01/2020  13:51            54,904 Qt53DQuickAnimation.dll
28/01/2020  13:51            76,408 Qt53DQuickExtras.dll
28/01/2020  13:51            51,832 Qt53DQuickInput.dll

You can install a separate installation of Qt if you want access to the tools (Qt Designer, Qt Creator, etc.) But this installation won’t affect your Python versions.

Hi @martin, thanks a lot!

I had no idea, and went to all the trouble of installing Qt itself prior to installing PySide2.

I installed PySide2 via pip in a virtual environment on Windows and I can confirm that I’ve got a lot of Qt5*.dll files in /path/to/my/venv/Lib/site-packages/PySide2. I’ll know it for next time. Thanks again!

I’m working on this template project for PySide2.
As you can read in the documentation, the user has to manually add the path to lrelease.exe either to PATH or to a new environmental variable named LRELEASE_BIN.

Resources and translations

In order to ease the development process, the Qt Creator project is provided. You can open it to edit the UI files or to manage resources. Translations can be edited using Qt Linguist, part of the Qt SDK. In order to build the translations, you will need to have the lrelease command on your PATH or set its full path to the LRELEASE_BIN environment variable. UI files, translations and resources can be built like this:

python build_res

As part of the changes I’m making to my fork, I’d like to use lrelease from the PySide2 package installed inside the virtual environment.
It would avoid having to install Qt and make all the dependencies self contained. The problem is that when I try to launch python.exe .\ build_res with the local path to lrelease.exe

lrelease = ".venv/Lib/site-packages/PySide2/lrelease.exe"
check_call([lrelease, ""])

I get the following error:

"C:/Users/my_user/path_to_my_project/.venv/Lib/site-packages/PySide2/lrelease-pro.exe" Not Recognized As an Internal or External Command


subprocess.CalledProcessError: Command '['.venv/Lib/site-packages/PySide2/lrelease.exe', '']' returned non-zero exit status 1.

Is there a way to rely on the lrelease executable installed by pip?

By the way, the post is copypasta of my question on StackOverflow, but I think it’s directly related with this thread because the only way I’ve found to make it work is by installing Qt

1 Like

Hi Jack, I’ve replied on StackOverflow, as I feel that your problem is very specific to what you’re trying to achieve. The short version is that the parts of Qt provided by PySide2 for its own usage are likely not meant to support every use case that the full Qt SDK supports, and in particular, probably not your use case.

Hopefully the potential alternatives I mention can help. Good luck!