我正在通过Remote Explorer模块在与VSCODE连接的Ubuntu 20.04 AWS-Ec2实例中运行Opencv 4.4.0。
我正在尝试打开已上传到项目中的图像。
import cv2
img = cv2.imread("imgs/cat1.jpg")
cv2.imshow("Output", img)
(env) ubuntu@ip-xxx-xx-xx-xxx:~/vhosts/opencv-ml-images$ /bin/python3 /home/ubuntu/vhosts/opencv-ml-images/chapter1.py
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/ubuntu/.local/lib/python3.8/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.
Aborted (core dumped)
有人知道发生了什么吗?也许与我在远程计算机上运行opencv有关的东西?如何播种?
答案 0 :(得分:0)
我认为您要尝试在远程桌面连接上运行它。我遇到了同样的问题,但是我正在运行WSL 2(两者都非常相似)。我通过从https://wiki.ubuntu.com/WSL在WSL 2上为GUI应用程序设置环境来解决了这个问题。只需启动X服务器,然后再次运行代码即可。它应该工作。如果没有,请回复,以便我们一起整理。