[Python] trying to use GUI in WSL2: qt.qpa.xcb: could not connect to display qt.qpa.plugin:...

Discussão em 'Python' iniciado por Stack, Setembro 23, 2024.

  1. Stack

    Stack Membro Participativo

    Trying to start on opencv, but nothing worked. I have tried almost every single link available

    I tried using opencv-python-headless, opencv-python, opencv-contrib-python

    Here's what I have:

    NOTE: the python download I'll explain a bit more on what I have done
    Package Version
    ---------------------- ---------
    numpy 2.1.1
    opencv-python-headless 4.10.0.84
    pip 22.0.2
    setuptools 59.6.0


    Here's the version of python I am using: Python 3.10.12. I am running everything in a virtual environment

    I also use the latest version of everything.

    When I use opencv-python, opencv-contrib-python, it gives this error:

    qt.qpa.xcb: could not connect to display
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb",....,


    even though it is found

    when I use opencv-python-headless, it gives me this error:

    cv2.namedWindow(window_name)
    cv2.error: OpenCV(4.10.0) /io/opencv/modules/highgui/src/window.cpp:1284: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'


    After some research, I think it is because opencv-python-headless don't support GUI, which I need for this tutorial. I'll talk more about it in what I have tried

    So, I believe I can not use opencv-python-headless, because it doesn't work with the tutorial I am on.

    BUT IF I AM WRONG PLEASE CORRECT ME

    So I started with opencv-python and followed these links: text

    text

    I tried uninstalling opencv-python and reinstalling, but it doesn't work, so I moved on to opencv-python-headless and got another error (READ the detail for the error message)

    so, I use these links:

    text text

    THEY TOLD ME TO UNINSTALL opencv-python-headless and reinstall opencv-python, unintall it and install it again

    So, I am back to square one.

    So, I did more research and come with this link from a Chinese website (so translate it first) text

    It told me to install opencv-contrib-python I found a reddit link that told me the same thing text

    NOTE: I did all when I still have my opencv-python-headless, so the error message is different

    NOTE: I tried a lot of other links, but these are the most "helpful" ones

    And I am back to square one after 7 hours. Pls help

    Continue reading...

Compartilhe esta Página