Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks
likehengqq opened this issue Sep 12, 2022 · 26 comments
Open
4 tasks

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

likehengqq opened this issue Sep 12, 2022 · 26 comments

Comments

@likehengqq
Copy link

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
@likehengqq likehengqq 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 Sep 12, 2022
@KaranParekh11
Copy link

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

@hitbuyi
Copy link

hitbuyi commented Oct 10, 2022

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?

@likehengqq
Copy link
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.

@bengabp
Copy link

bengabp commented Oct 31, 2022

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.

@bengabp
Copy link

bengabp commented Nov 1, 2022

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?

@asmorkalov
Copy link
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.

@asmorkalov asmorkalov self-assigned this Nov 17, 2022
@Viha123
Copy link

Viha123 commented Jan 21, 2023

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?

@asmorkalov
Copy link
Collaborator

@asmorkalov
Copy link
Collaborator

asmorkalov commented Jan 26, 2023

@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.

@asmorkalov
Copy link
Collaborator

#784

@vineoak
Copy link

vineoak commented Feb 16, 2023

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.

@asmorkalov
Copy link
Collaborator

Thanks. I got the same result with Kubuntu 22.04. It looks like I missed something in package.

@mahyarmirrashed
Copy link

Is there any way to silence this message for now in the terminal?

@Petros626
Copy link

Petros626 commented Feb 28, 2023

@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.

@jeroenvermunt
Copy link

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

@asmorkalov
Copy link
Collaborator

Not yet for now.

@git-sparrowlinux
Copy link

git-sparrowlinux commented Sep 13, 2023

disable wayland in ubuntu system

go to /etc/gdm3/custom.conf and uncomment the "WaylandEnable=false"

Uncomment the line below to force the login screen to use Xorg
WaylandEnable=false

then restart the PC

@MasterHM-ml
Copy link

  1. try sudo pip install opencv-python-headless

second option worked for me. thanks

@MeqdadDev
Copy link

MeqdadDev commented Nov 10, 2023

Same issue here, but the code itself is working fine. I've tried @ultimateagain steps and disabled this warning message.

Environment:
OS: Ubuntu 22.04
Python: v3.10.12

@jwillikers
Copy link

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.

@rouftom
Copy link

rouftom commented Nov 23, 2023

Try this:

import os
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = "wayland"

@MasterHM-ml
Copy link

QT_QPA_PLATFORM=xcb

If you're not in conda environment, this solution will work best

pip3 install opencv_python
export QT_QPA_PLATFORM=xcb

this will work best in the current on terminal only. For permanent change do

echo "export QT_QPA_PLATFORM=xcb" >> ~/.profile

and restart/logout

@mak448a
Copy link

mak448a commented Dec 20, 2023

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!

@golfinq
Copy link

golfinq commented Jan 1, 2024

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

@Avasam
Copy link

Avasam commented Jan 6, 2024

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

@EnziinSystem
Copy link

EnziinSystem commented May 18, 2024

@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"

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

No branches or pull requests