Python library(pyside6) with nixld

Hi im trying to use pyside6 for a python app in my senior design class. The nix version of pyside6 does not include uic-pyside6 Relevant github issue, which I need to get the .ui file converted to .py from where its been made in QTDesigner. So my solution to this currently is using a distrobox with ubuntu and python installed to either run the script or just run the ui conversion then exit. What i would prefer is being able to use nix-ld to run pyside 6 with uv.

My nixld is setup as follows.

programs.nix-ld = {
    enable = true;
    libraries = options.programs.nix-ld.libraries.default ++ (
      with pkgs; [
        glib # libglib-2.0.so.0
        libGL
        libxkbcommon
        fontconfig
        libx11
        freetype
        dbus
        libxcb-cursor
        kdePackages.qtbase
        kdePackages.qtwayland
           kdePackages.qt3d

    kdePackages.qtcharts
    kdePackages.qtconnectivity
    kdePackages.qtdatavis3d
    kdePackages.qtdeclarative
    kdePackages.qthttpserver
    kdePackages.qtmultimedia
    kdePackages.qtnetworkauth
    kdePackages.qtquick3d
    kdePackages.qtremoteobjects
    kdePackages.qtscxml
    kdePackages.qtsensors
    kdePackages.qtspeech
    kdePackages.qtsvg
    kdePackages.qtwebchannel
    kdePackages.qtwebsockets
    kdePackages.qtwebview
    kdePackages.qtpositioning
    kdePackages.qtlocation
    kdePackages.qtshadertools
    kdePackages.qtserialport
    kdePackages.qtserialbus
    kdePackages.qtgraphs
    kdePackages.qttools
           ]
    );
  };

This was done as with only glib and libGL the script would fail and then complain about missing libraries ex ImportError: libX11.so.6: cannot open shared object file: No such file or directory. With the above setup im now facing the following error and im unsure how to proceed. In other news uic-pyside6 now works :sob:

(pc-software) irrelevancy@Jester ~/p/App (develop) [1]> python3.14 ./main.py
Traceback (most recent call last):
File “/home/irrelevancy/pc-software/App/./main.py”, line 1, in
from PySide6.QtWidgets import (
…<6 lines>…
)
ImportError: /run/current-system/sw/share/nix-ld/lib/libQt6DBus.so.6: undefined symbol: _ZN14QObjectPrivateC2E16QtPrivate_6_10_1, version Qt_6_PRIVATE_API

Hey! This is a Qt version mismatch. PySide6 from pip/uv ships its own Qt6 libraries, but your nix-ld config also provides Qt6 via all the kdePackages.* entries. When PySide6 loads, it picks up the system Qt first and they clash.

Fix: remove all kdePackages.* from your nix-ld libraries. Keep only the low-level stuff like glib, libGL, libxkbcommon, fontconfig, freetype, dbus, xorg.libX11, xorg.libxcb. PySide6 will use its own bundled Qt and it should work. If it complains about a missing .so after that, just add that specific lib back.

References: Qt Forum – PySide6 library conflict, NixOS Wiki – nix-ld (recommended library list has no Qt packages for this reason)

Hope that helps!

So i removed the kdepackages.* stuff and now i get the following error

qt.qpa.plugin: Could not load the Qt platform plugin “wayland” in “” even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-brcm, wayland-egl, wayland, xcb.

fish: Job 1, ‘python3.14 ./main.py’ terminated by signal SIGABRT (Abort)

I use niri with wayland currently if i set the qt_qpa_platform to xcb
i end up with

(pc-software) irrelevancy@Jester ~/p/App (develop)> python3.14 ./main.pyqt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-brcm, wayland-egl, wayland, xcb.

fish: Job 1, ‘python3.14 ./main.py’ terminated by signal SIGABRT (Abort)

Is there a way to figure out whats missing on either so i can get the gui from my program to load? preferably in wayland.

Hi i fear im still stuck as i get an error that no qt platform plugin could be initialized. i set QT_DEBUG_PLUGINS=1 and get the following message

qt.core.plugin.factoryloader: checking directory path "/nix/store/vh9268xkisfgf565nlxarfh53bw6im4b-home-manager-path/lib/qt-5.15.18/plugins/platforms" ...
qt.core.plugin.factoryloader: checking directory path "/nix/store/vh9268xkisfgf565nlxarfh53bw6im4b-home-manager-path/lib/qt-6/plugins/platforms" ...
qt.core.plugin.factoryloader: checking directory path "/nix/store/xzgdvp16vx4wx1w38wig45b0hhswl389-qt5ct-1.9/lib/qt-5.15.18/plugins/platforms" ...
qt.core.plugin.factoryloader: checking directory path "/nix/store/zyp3y5nlsa16ad7w05fck17b88axqxaf-qt6ct-0.11/lib/qt-6/plugins/platforms" ...
qt.core.plugin.factoryloader: checking directory path "/home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms" ...
qt.core.plugin.factoryloader: looking at "libqeglfs.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archlevel": 2,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("eglfs")
qt.core.plugin.factoryloader: looking at "libqlinuxfb.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqlinuxfb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "linuxfb"
        ]
    },
    "archlevel": 2,
    "className": "QLinuxFbIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("linuxfb")
qt.core.plugin.factoryloader: looking at "libqminimal.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqminimal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archlevel": 2,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal")
qt.core.plugin.factoryloader: looking at "libqminimalegl.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqminimalegl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimalegl"
        ]
    },
    "archlevel": 2,
    "className": "QMinimalEglIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimalegl")
qt.core.plugin.factoryloader: looking at "libqoffscreen.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqoffscreen.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archlevel": 2,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen")
qt.core.plugin.factoryloader: looking at "libqvkkhrdisplay.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqvkkhrdisplay.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "vkkhrdisplay"
        ]
    },
    "archlevel": 2,
    "className": "QVkKhrDisplayIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vkkhrdisplay")
qt.core.plugin.factoryloader: looking at "libqvnc.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqvnc.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "vnc"
        ]
    },
    "archlevel": 2,
    "className": "QVncIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vnc")
qt.core.plugin.factoryloader: looking at "libqwayland.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqwayland.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "wayland",
            "wayland-egl",
            "wayland-brcm"
        ]
    },
    "archlevel": 2,
    "className": "QWaylandIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("wayland", "wayland-egl", "wayland-brcm")
qt.core.plugin.factoryloader: looking at "libqxcb.so"
qt.core.plugin.loader: Found metadata in lib /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archlevel": 2,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 395776
}


qt.core.plugin.factoryloader: Got keys from plugin meta data QList("xcb")
qt.core.plugin.factoryloader: checking directory path "/home/irrelevancy/.local/share/uv/python/cpython-3.14.2-linux-x86_64-gnu/bin/platforms" ...
qt.core.library: "/home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqwayland.so" cannot load: Cannot load library /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqwayland.so: libwayland-client.so.0: cannot open shared object file: No such file or directory
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqwayland.so" : "Cannot load library /home/irrelevancy/pc-software/.venv/lib/python3.14/site-packages/PySide6/Qt/plugins/platforms/libqwayland.so: libwayland-client.so.0: cannot open shared object file: No such file or directory"
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-brcm, wayland-egl, wayland, xcb.

So after discussing with friends at my schools lug who are nixos users the best path forward seems like just using a distrobox for the script.

1 Like