Skip to content

Could not find the Qt platform plugin "wayland" in opencv path #729

Open

Description

@likehengqq

Expected behaviour

Write here how did you expect the library to function.

Actual behaviour

Write here what went wrong.

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/firefly/venv/lib/python3.9/site-packages/cv2/qt/plugins"
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.

Aborted (core dumped)

Steps to reproduce

  • example code
import cv2
cap=cv2.VideoCapture(8)
while True:
    ret,frame =cap.read()
    frame=cv2.flip(frame,1)
    cv2.imshow('frame',frame)
    if cv2.waitKey(1)&0xff==ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
  • operating system: ubuntu 20.04
  • architecture (e.g. x86): aarch64
  • opencv-python version: opencv_python-4.5.1.48-cp39-cp39
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

Activity

  1. changed the title [-]ould not find the Qt platform plugin "wayland" in opencv path[/-] [+]Could not find the Qt platform plugin "wayland" in opencv path[/+] on Sep 12, 2022
  2. KaranParekh11 commented on Sep 29, 2022

    @KaranParekh11

    i also have same problem with latest version of opencv-python.If any one was able to solve this issue please reply here.

  3. hitbuyi commented on Oct 10, 2022

    @hitbuyi

    I have the same problem for opencv-python 4.5.x,4.6.x, the error message is

    Connected to pydev debugger (build 201.8538.36)
    QObject::moveToThread: Current thread (0x55ae47946190) is not the object's thread (0x55ae4795d6b0).
    Cannot move to target thread (0x55ae47946190)
    
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/hitbuyi/.conda/envs/py1121/lib/python3.9/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, webgl.
    

    My environments are
    OS: ubuntu20.04
    Conda: 4.43
    python: 3.9
    opencv-python: 4.5.x,4.6.x

    Any progress in this issue?

  4. likehengqq commented on Oct 17, 2022

    @likehengqq
    Author

    i also have same problem with latest version of opencv-python.If any one was able to solve this issue please reply here.

    You can try lowering the Python version.

  5. bengabp commented on Oct 31, 2022

    @bengabp

    Hello guys,please I need help about this. I am getting same error here also and its not allowing video stream to continue.

    qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/bengab/venv/lib/python3.10/site-packages/cv2/qt/plugins

    image

    @likehengqq I have also tried decreasing the opencv-python version but its still not working.

  6. bengabp commented on Nov 1, 2022

    @bengabp

    Guys the error shows but it still works. It shows like some kind of warning and it does not prevent my program from running. But when I use ffpyplayer to also read audio the error shows but this time it will not allow my program to run further.

    Please what is the cause of this strange behavior?

  7. asmorkalov commented on Nov 17, 2022

    @asmorkalov
    Collaborator

    OpenCV distributes own instance of QT to facilitate imshow and some other UI functions. Own QT built is done without wayland support: https://github.com/opencv/opencv-python/blob/4.x/docker/manylinux2014/Dockerfile_x86_64#L59. I'll take a look if we can add this option to the package for the next release.

  8. self-assigned this
    on Nov 17, 2022
  9. Viha123 commented on Jan 21, 2023

    @Viha123

    Hello guys,please I need help about this. I am getting same error here also and its not allowing video stream to continue.

    qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/bengab/venv/lib/python3.10/site-packages/cv2/qt/plugins

    image

    @likehengqq I have also tried decreasing the opencv-python version but its still not working.

    yep similar issue here were you able to figure it out?

  10. asmorkalov commented on Jan 24, 2023

    @asmorkalov
    Collaborator
  11. asmorkalov commented on Jan 26, 2023

    @asmorkalov
    Collaborator

    @likehengqq @bengabp @KaranParekh11 Could you try to install experimental package with Qr 5.15.8 and Wayland plugin enabled for build: https://github.com/opencv/opencv-python/actions/runs/4012888768? I need feedback from real Wayland-based system.

  12. asmorkalov commented on Feb 3, 2023

    @asmorkalov
    Collaborator
  13. vineoak commented on Feb 16, 2023

    @vineoak

    I tested out your provided wheel opencv_contrib_python-4.7.0.3564733-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl with wayland enabled environment and pyqt 5.15.8 installed on Ubuntu 22.04 and can confirm the same output as I now found on your PR #784. Hope this still helps.

    qt.qpa.wayland: Failed to load client buffer integration: "wayland-egl"
    qt.qpa.wayland: Available client buffer integrations: ()
    qt.qpa.wayland: No shell integration named "xdg-shell" found
    qt.qpa.wayland: No shell integration named "xdg-shell-v6" found
    qt.qpa.wayland: No shell integration named "wl-shell" found
    qt.qpa.wayland: No shell integration named "ivi-shell" found
    qt.qpa.wayland: Loading shell integration failed.
    qt.qpa.wayland: Attempted to load the following shells ("xdg-shell", "xdg-shell-v6", "wl-shell", "ivi-shell")
    

    edit: I can also confirm that the wheel you built works nicely when I change the session to X11.

  14. 11 remaining items

  15. mak448a commented on Dec 20, 2023

    @mak448a

    I am on Wayland and seeing the same result as @vineoak, is there a solution without having to swich to X11?

    @jeroenvermunt, setting QT_QPA_PLATFORM=xcb when running OpenCV should launch under XWayland without requiring you to switch your session over to X11.

    It works!

  16. golfinq commented on Jan 1, 2024

    @golfinq

    A workaround I found was to use xwayland-run which spawns an xwayland instance for opencv to run in. I did it with QT_QPA_PLATFORM=xcb xwayland-run -- pipenv run python ... where pipenv installed opencv-python, opencv-contrib-python, and opencv-python-headless into a virtual environment

  17. Avasam commented on Jan 6, 2024

    @Avasam

    Could be related, if not the exact same issue, since the problem is with bundled QT: https://bugreports.qt.io/browse/QTBUG-114635

  18. EnziinSystem commented on May 18, 2024

    @EnziinSystem

    @mahyarmirrashed yes it is. So there 3 ways I 've proven to work to suppress this message:

    1. use os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH") after import cv2
    2. try sudo pip install opencv-python-headless
    3. delete the libqxcb frm OpenCV in /home/yourname/.local/lib/python3.9/site-packages/cv2/qt/plugins/platforms

    In the Thonny IDE commen in no. 1 works fine should in terminal too.

    The problem is that opencv-python does not come with a library for Wayland so QT_QPA_PLATFORM_PLUGIN_PATH has no value and does not point to any location.

    Therefore, your method does not solve the problem on systems operating based on Wayland such as Raspberry Pi-5.

    $ ls .local/lib/python3.11/site-packages/opencv_python.libs
    libavcodec-03bb4e36.so.59.37.100   libQt5Test-32fc1c2a.so.5.15.0      libxcb-icccm-05fb8c7f.so.4.0.0        libxcb-util-c74d156a.so.1.0.0
    libavformat-1279b9be.so.59.27.100  libQt5Widgets-b1296c1e.so.5.15.0   libxcb-image-75825d2e.so.0.0.0        libxcb-xfixes-f4cf71d4.so.0.0.0
    libavutil-f0a93969.so.57.28.100    libQt5XcbQpa-7b9d0389.so.5.15.0    libxcb-keysyms-73cd270d.so.1.0.0      libxcb-xinerama-6372573d.so.0.0.0
    libcrypto-956af892.so.1.1          libssl-b9692d76.so.1.1             libxcb-randr-e1606dfc.so.0.1.0        libxcb-xkb-e2f6f9de.so.1.0.0
    libgfortran-8634ef04.so.3.0.0      libswresample-39e38dfb.so.4.7.100  libxcb-render-76b15fe5.so.0.0.0       libxkbcommon-e272a37d.so.0.0.0
    libopenblas-r0-8966572e.3.3.so     libswscale-86dc6859.so.6.7.100     libxcb-render-util-486ef3ee.so.0.0.0  libxkbcommon-x11-b76c7d31.so.0.0.0
    libpng16-45e47e2f.so.16.40.0       libvpx-b07bc8cf.so.8.0.1           libxcb-shape-e8fe4bc4.so.0.0.0
    libQt5Core-9e162752.so.5.15.0      libX11-xcb-8ab4be54.so.1.0.0       libxcb-shm-cad72500.so.0.0.0
    libQt5Gui-08f6a1f3.so.5.15.0       libXau-21870672.so.6.0.0           libxcb-sync-dc271c48.so.1.0.0
    

    There is no Wayland library.

    RUN curl -C - -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
        tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
        cd qt-everywhere-src-${QT_VERSION} && \
        export MAKEFLAGS=-j$(nproc) && \
        ./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip translations \
     -skip qtwayland \
    -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
        make && \
        make install && \
        cd .. && \
        rm -rf qt-everywhere*
    
    

    The deeper cause lies in the Dockerfile build operation, which ignored the Wayland build "-skip qtwayland"

  19. cccmmmhhh commented on Oct 4, 2024

    @cccmmmhhh

    @mahyarmirrashed yes it is. So there 3 ways I 've proven to work to suppress this message:是的,它是。所以我已经证明有三种方法可以有效地抑制这种信息:

    1. use os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH") after import cv2 使用后
    2. try 试一试sudo pip install opencv-python-headless
    3. delete the libqxcb frm OpenCV in /home/yourname/.local/lib/python3.9/site-packages/cv2/qt/plugins/platforms从OpenCV中删除libqxcb

    In the Thonny IDE commen in no. 1 works fine should in terminal too.在tony IDE的评论中没有。我也应该在终端工作。

    The problem is that opencv-python does not come with a library for Wayland so QT_QPA_PLATFORM_PLUGIN_PATH has no value and does not point to any location.问题是opencv-python没有为Wayland提供库,所以QT_QPA_PLATFORM_PLUGIN_PATH没有值,也不指向任何位置。

    Therefore, your method does not solve the problem on systems operating based on Wayland such as Raspberry Pi-5.因此,您的方法不能解决基于Wayland操作的系统(如Raspberry Pi-5)上的问题。

    $ ls .local/lib/python3.11/site-packages/opencv_python.libs
    libavcodec-03bb4e36.so.59.37.100   libQt5Test-32fc1c2a.so.5.15.0      libxcb-icccm-05fb8c7f.so.4.0.0        libxcb-util-c74d156a.so.1.0.0
    libavformat-1279b9be.so.59.27.100  libQt5Widgets-b1296c1e.so.5.15.0   libxcb-image-75825d2e.so.0.0.0        libxcb-xfixes-f4cf71d4.so.0.0.0
    libavutil-f0a93969.so.57.28.100    libQt5XcbQpa-7b9d0389.so.5.15.0    libxcb-keysyms-73cd270d.so.1.0.0      libxcb-xinerama-6372573d.so.0.0.0
    libcrypto-956af892.so.1.1          libssl-b9692d76.so.1.1             libxcb-randr-e1606dfc.so.0.1.0        libxcb-xkb-e2f6f9de.so.1.0.0
    libgfortran-8634ef04.so.3.0.0      libswresample-39e38dfb.so.4.7.100  libxcb-render-76b15fe5.so.0.0.0       libxkbcommon-e272a37d.so.0.0.0
    libopenblas-r0-8966572e.3.3.so     libswscale-86dc6859.so.6.7.100     libxcb-render-util-486ef3ee.so.0.0.0  libxkbcommon-x11-b76c7d31.so.0.0.0
    libpng16-45e47e2f.so.16.40.0       libvpx-b07bc8cf.so.8.0.1           libxcb-shape-e8fe4bc4.so.0.0.0
    libQt5Core-9e162752.so.5.15.0      libX11-xcb-8ab4be54.so.1.0.0       libxcb-shm-cad72500.so.0.0.0
    libQt5Gui-08f6a1f3.so.5.15.0       libXau-21870672.so.6.0.0           libxcb-sync-dc271c48.so.1.0.0
    

    There is no Wayland library.没有韦兰图书馆。

    RUN curl -C - -O -L https://download.qt.io/official_releases/qt/5.15/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz && \
        tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz && \
        cd qt-everywhere-src-${QT_VERSION} && \
        export MAKEFLAGS=-j$(nproc) && \
        ./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip translations \
     -skip qtwayland \
    -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \
        make && \
        make install && \
        cd .. && \
        rm -rf qt-everywhere*
    

    The deeper cause lies in the Dockerfile build operation, which ignored the Wayland build "-skip qtwayland"更深层次的原因在于Dockerfile的构建操作,它忽略了Wayland的构建“-skip qtwayland”

    I agree with you. How did you solve it in the end?

  20. sebbean commented on Oct 22, 2024

    @sebbean

    @golfinq

    xwayland-run

    how do i find this command? I have wayland running, but i cant seem to find this binary or package

    #729 (comment)

  21. GastonMelo commented on Nov 6, 2024

    @GastonMelo

    Hi to all, Im using ubuntu OS 64 with VSCode, I have created a folder in which a create a virtualenv to run code. Im trying to use cv2 to refresh images, and got this warning:
    qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/gaston/esp32_projects/gpio_test/python_rgb/.venv/lib/python3.12/site-packages/cv2/qt/plugins"
    and th eprogram just stop working. I have tried to install Qt5 in the venv, tried to install opencv-python-headless but the problem persist. I tried to install pywayland using pip install but got the same error. How to solve it?

  22. mak448a commented on Nov 6, 2024

    @mak448a

    Did you try #729 (comment)?
    Also, @sebbean, try installing it with

    sudo apt install xwayland-run
  23. GastonMelo commented on Nov 6, 2024

    @GastonMelo

    how do I solve this in the virtualenv? Im using VSCode in this venv and I already tried to install python headless, set envirnoment variables in the activate script, before start the venv.

  24. mak448a commented on Nov 6, 2024

    @mak448a

    Did you try echo "export QT_QPA_PLATFORM=xcb" >> ~/.bashrc and then installing normal opencv?

  25. GastonMelo commented on Nov 6, 2024

    @GastonMelo

    Im still gettin gthis error:
    qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/gaston/esp32_projects/gpio_test/python_rgb/.venv/lib/python3.12/site-packages/cv2/qt/plugins"

    inside that folder I got only this: libqxcb.so

  26. mak448a commented on Nov 7, 2024

    @mak448a

    I'm not sure then. If you want to undo the changes to your system that was applied through the command I gave previously, you can remove export QT_QPA_PLATFORM=xcb from the file ~/.bashrc

  27. An-Gabhar1 commented on Nov 9, 2024

    @An-Gabhar1

    Did you try #729 (comment)? Also, @sebbean, try installing it with

    sudo apt install xwayland-run

    (Ubuntu 22.04)
    I did and the result is:

    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    E: Unable to locate package xwayland-run

  28. golfinq commented on Nov 9, 2024

    @golfinq

    xwayland-run is a script utility found here: https://gitlab.freedesktop.org/ofourdan/xwayland-run

  29. JayAitchh commented on May 23, 2025

    @JayAitchh

    Hello, none of the suggested issues work in a virtual environment, at least for me. Anyone found a solution for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions