opencv-python
opencv-python copied to clipboard
Could not find the Qt platform plugin "wayland" in opencv path
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
i also have same problem with latest version of opencv-python.If any one was able to solve this issue please reply here.
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?
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.
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

@likehengqq I have also tried decreasing the opencv-python version but its still not working.
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?
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.
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
@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?
Related: https://stackoverflow.com/questions/68417682/qt-and-opencv-app-not-working-in-virtual-environment
@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.
https://github.com/opencv/opencv-python/pull/784
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.
Thanks. I got the same result with Kubuntu 22.04. It looks like I missed something in package.
Is there any way to silence this message for now in the terminal?
@mahyarmirrashed yes it is. So there 3 ways I 've proven to work to suppress this message:
- use
os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH")afterimport cv2 - try
sudo pip install opencv-python-headless - 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.
I am on Wayland and seeing the same result as @vineoak, is there a solution without having to swich to X11?
Not yet for now.
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
- try
sudo pip install opencv-python-headless
second option worked for me. thanks
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
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.
Try this:
import os
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = "wayland"
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
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=xcbwhen running OpenCV should launch under XWayland without requiring you to switch your session over to X11.
It works!
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
Could be related, if not the exact same issue, since the problem is with bundled QT: https://bugreports.qt.io/browse/QTBUG-114635
@mahyarmirrashed yes it is. So there 3 ways I 've proven to work to suppress this message:
- use
os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH")afterimport cv2- try
sudo pip install opencv-python-headless- delete the libqxcb frm OpenCV in
/home/yourname/.local/lib/python3.9/site-packages/cv2/qt/plugins/platformsIn 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"