[Python] Qt Application Fails to Load XCB Platform Plugin on Raspberry Pi 5 with PySide2

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am running a PySide2 (Qt5) application on a Raspberry Pi 5 with Raspberry Pi OS Lite (64-bit, November 2024 release). When I try to run my script (python main.py), I get the following error:

    Got keys from plugin meta data ("xcb")
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
    loaded library "/home/mindrontm/.local/lib/python3.11/site-packages/cv2/qt/plugins/platforms/libqxcb.so"
    QObject::moveToThread: Current thread (0x2e862dc0) is not the object's thread (0x2e867840).
    Cannot move to target thread (0x2e862dc0)

    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/mindrontm/.local/lib/python3.11/site-packages/cv2/qt/plugins" 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: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx.

    Aborted



    System Information Device: Raspberry Pi 5 OS: Raspberry Pi OS Lite (64-bit, November 2024) Python: 3.11 Qt Version: 5 (installed via system packages) PySide2 Version: Latest from pip

    What I Have Tried

    Forcing the correct Qt path:

    export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms
    export QT_PLUGIN_PATH=/usr/lib/aarch64-linux-gnu/qt5/plugins
    export QT_QPA_PLATFORM=xcb
    python main.py



    Running without OpenCV's path:

    PYTHONPATH="" python main.py

    Reinstalling OpenCV without Qt support:

    pip uninstall opencv-python
    pip install opencv-python-headless



    Checking missing dependencies:

    `ldd /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so

    Reinstalling Qt plugins:

    sudo apt update
    sudo apt install --reinstall qt5-qpa-platform-plugins



    this is link to error log

    Error.txt

    Continue reading...

Compartilhe esta Página