我正在尝试运行一些图像识别教程,但我不断遇到此错误,导致我无法继续。我正在运行 Ubuntu 21.10 和 Python 3.9.7。我的代码是这样的。
import cv2
img=cv2.imread("path",1)
#print(type(img))
#print(img)
#print(img.shape)
#print(img.ndim)
cv2.imshow("Moon",img)
cv2.waitKey(2000)
Run Code Online (Sandbox Code Playgroud)
更重要的是,这是我得到的错误:
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "/home/peepo/.local/lib/python3.9/site-packages/cv2/qt/plugins"
Run Code Online (Sandbox Code Playgroud)
我转到路径中的文件夹,果然,Wayland 不在那里。我已经搜索了一段时间并安装了几种不同的东西,从解决方案到我在网上找到的经历类似事情的人。没有任何效果。
目前,我正在寻找是否有一些手动下载的地方,我可以将其拖放到文件夹中。我读到新版本的 Ubuntu 和 qt4 存在一些问题,所以我不确定这更多的是 Ubuntu 还是 Python 问题。任何帮助,将不胜感激。
小智 21
我在尝试使用 Wayland 启动 KeepassXC 2.6.6 时遇到了同样的问题:
QT_QPA_PLATFORM=wayland keepassxc
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 ""
Run Code Online (Sandbox Code Playgroud)
Ubuntu 21.10 和 22.04 上的解决方案是安装qtwayland5:
sudo apt install qtwayland5
Run Code Online (Sandbox Code Playgroud)
Mat*_*aun 12
当我尝试在运行 Sway 作为窗口管理器的 Arch Linux 上启动OBS Studio 27.1.3时,遇到了非常类似的错误。OBS产生了这个错误:
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
Run Code Online (Sandbox Code Playgroud)
此错误报告表明我缺少qt5-wayland通过安装它修复的依赖项:
pacman -S qt5-wayland
Run Code Online (Sandbox Code Playgroud)
之后OBS运行一切正常,能够录制屏幕和音频。
小智 2
升级到 Ubuntu 21.10(从 20.10 开始)后,我遇到了同样的问题。
安装旧版本的 OpenCV 对我有用。
pip install opencv-python==4.3.0.38
Run Code Online (Sandbox Code Playgroud)