Installation of pyside6

Hi there, new to nix and I was trying to install pyside6 through virtualenv and got this error.

$ python test_pyside.py                                                                                                       
Traceback (most recent call last):
  File "test_pyside.py", line 2, in <module>
    from PySide6.QtCore import Qt
ImportError: libglib-2.0.so.0: cannot open shared object file: No such file or directory

Then I tried to find the runtime libraries needed for it using ldd.

 $ ldd venv/lib/python3.8/site-packages/PySide6/libpyside6.abi3.so.6.1                                                       
        linux-vdso.so.1 (0x000068752139c000)
        libshiboken6.abi3.so.6.1 => not found
        libQt6Qml.so.6 => /home/quark/4-X PHOTON/0_DEV/1_REPOS/pygui/venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Qml.so.6 (0x0000687520c1f000)
        libQt6Network.so.6 => /home/quark/4-X PHOTON/0_DEV/1_REPOS/pygui/venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Network.so.6 (0x0000687520a23000)
        libQt6Core.so.6 => /home/quark/4-X PHOTON/0_DEV/1_REPOS/pygui/venv/lib/python3.8/site-packages/PySide6/Qt/lib/libQt6Core.so.6 (0x0000687520426000)
        libstdc++.so.6 => /nix/store/dzaadhn5y56da24635icafv1nrawxm4n-gcc-10.3.0-lib/lib/libstdc++.so.6 (0x0000687520251000)
        libm.so.6 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libm.so.6 (0x000068752010c000)
        libgcc_s.so.1 => /nix/store/dzaadhn5y56da24635icafv1nrawxm4n-gcc-10.3.0-lib/lib/libgcc_s.so.1 (0x00006875200f2000)
        libpthread.so.0 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0 (0x00006875200d1000)
        libc.so.6 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6 (0x000068751ff10000)
        libdl.so.2 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libdl.so.2 (0x000068751ff0b000)
        libgssapi_krb5.so.2 => not found
        libz.so.1 => not found
        libicui18n.so.56 => /home/quark/4-X PHOTON/0_DEV/1_REPOS/pygui/venv/lib/python3.8/site-packages/PySide6/Qt/lib/libicui18n.so.56 (0x000068751fa70000)
        libicuuc.so.56 => /home/quark/4-X PHOTON/0_DEV/1_REPOS/pygui/venv/lib/python3.8/site-packages/PySide6/Qt/lib/libicuuc.so.56 (0x000068751f6b8000)
        libicudata.so.56 => /home/quark/4-X PHOTON/0_DEV/1_REPOS/pygui/venv/lib/python3.8/site-packages/PySide6/Qt/lib/libicudata.so.56 (0x000068751dcd5000)
        libglib-2.0.so.0 => not found
        libz.so.1 => not found
        libgthread-2.0.so.0 => not found
        librt.so.1 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/librt.so.1 (0x000068751dcc8000)
        /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib64/ld-linux-x86-64.so.2 (0x000068752139e000)

I know some of these library paths can be found and added to the variable to LD_LIBRARY_PATH.
I have also tried using nix-shell but pyside6 wasn’t available in nixpkgs. Is there a way pyside6 can be installed using nix-shell?

You should still be able to create an environment containing the libraries using nix-shell -p zlib libkrb5 … (or create a shell.nix file and then you can just run nix-shell without arguments).

I use nix-ld to fix those kinds of issues for me. Note, glib is not in its defaults, so you have to add it to the list of covered libraries, explicitly:

{ options, pkgs, ... }:
{
  programs.nix-ld = {
    enable = true;
    libraries = options.programs.nix-ld.libraries.default ++ (
      with pkgs; [
        glib # libglib-2.0.so.0
      ]
    );
  };
}

To make the picture complete, I install both the Python interpreter and Python packages using uv, e.g.

$ uv python install 3.13 --default --preview
$ uv run --with pyside6 python
Installed 4 packages in 90ms
Python 3.13.5 (main, Jun 26 2025, 21:20:04) [Clang 20.1.4 ] on linux
>>> from PySide6.QtCore import Qt
>>>