opencv-python: 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.)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 25
@mahyarmirrashed yes it is. So there 3 ways I 've proven to work to suppress this message:
os.environ.pop("QT_QPA_PLATFORM_PLUGIN_PATH")
afterimport cv2
sudo pip install opencv-python-headless
/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 also have same problem with latest version of opencv-python.If any one was able to solve this issue please reply here.
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.
I have the same problem for opencv-python 4.5.x,4.6.x, the error message is
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?
If you’re not in conda environment, this solution will work best
this will work best in the current on terminal only. For permanent change do
echo "export QT_QPA_PLATFORM=xcb" >> ~/.profile
and restart/logout
@jeroenvermunt, setting
QT_QPA_PLATFORM=xcb
when running OpenCV should launch under XWayland without requiring you to switch your session over to X11.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
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.edit: I can also confirm that the wheel you built works nicely when I change the session to X11.