qt.qpa.plugin: Could not find the Qt platform plugin "wayland"
Nov 16
I'm trying to run some code that uses Qt GUI, but I keep running into this error that's preventing me from proceeding. I'm running Ubuntu 21.10, and Python 3.9.7. My code is as such.
This is the error I get:
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/peepo/.local/lib/python3.9/site-packages/cv2/qt/plugins"
I went to the folder in the path and sure enough, Wayland isn't there. I've been searching around for a while now and installed several different things from solutions to people experiencing similar things I've found on the web. Nothing has worked.
Currently I'm at the point where I'm looking to see if there's some manual download somewhere that I can just drag and drop into the folder. I've read that there are some issues with the new version of Ubuntu and qt4, so I'm not sure if this is more of an Ubuntu or Python problem. Any help would be appreciated.
This is the code that tries to use Qt GUI:
import cv2
img = cv2.imread("path")
cv2.imshow("window", img)
cv2.waitKey()
1 answer
Accepted answer · original discussion
Nov 17
I got the same issue after upgrading to Ubuntu 21.10 (from 20.10).
Installing an older version of OpenCV worked for me.
pip install opencv-python==4.3.0.38
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
May 31
export QT_QPA_PLATFORM=xcb