qt.qpa.xcb:在 ec2 ubuntu 服务器 20.0 上使用 OpenCV 时无法连接到显示错误

问题描述 投票:0回答:2

我正在尝试运行这里提到的 Tesseract Ocr 代码 https://www.pyimagesearch.com/2018/09/17/opencv-ocr-and-text-recognition-with-tesseract/ 在 ec2 ubuntu 服务器 20.0 上。

我遇到错误:

cv2.imshow("Text Detection", output)

错误如下:

qt.qpa.xcb:无法连接到显示器 qt.qpa.plugin:即使找到了“/usr/local/lib/python3.8/dist-packages/cv2/qt/plugins”中的Qt平台插件“xcb”,也无法加载它。 该应用程序无法启动,因为无法初始化 Qt 平台插件。重新安装应用程序可能会解决此问题。

可用的平台插件有:xcb、eglfs、linuxfb、minimal、minimalegl、offscreen、vnc。

中止(核心转储)

我知道这行代码会打开一个窗口来显示检测到的输出图像,但该窗口没有显示。请帮助解决错误。

opencv ubuntu amazon-ec2 xcb
2个回答
0
投票

您收到此错误是因为没有 UI 可打开窗口并显示图像。

快速解决方法是保存并下载图像。并在本地查看。

另一种方法是设置 XServer 并通过 SSH 启用 X11 转发。


0
投票
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libgl1-mesa-glx : Depends: libgl1 but it is not going to be installed
                   Depends: libglx-mesa0 but it is not going to be installed
 libgtk2.0-dev : Depends: libgtk2.0-0 (= 2.24.32-4ubuntu4) but it is not going to be installed
                 Depends: gir1.2-gtk-2.0 (= 2.24.32-4ubuntu4) but it is not going to be installed
                 Depends: libgtk2.0-common but it is not going to be installed
                 Depends: libglib2.0-dev (>= 2.27.3) but it is not going to be installed
                 Depends: libgdk-pixbuf2.0-dev (>= 2.21.0) but it is not going to be installed
                 Depends: libpango1.0-dev (>= 1.20) but it is not going to be installed
                 Depends: libatk1.0-dev (>= 1.29.2) but it is not going to be installed
                 Depends: libcairo2-dev (>= 1.6.4-6.1) but it is not going to be installed
                 Depends: libx11-dev (>= 2:1.0.0-6) but it is not going to be installed
                 Depends: libxext-dev (>= 1:1.0.1-2) but it is not going to be installed
                 Depends: libxinerama-dev (>= 1:1.0.1-4.1) but it is not going to be installed
                 Depends: libxi-dev (>= 1:1.0.1-4) but it is not going to be installed
                 Depends: libxrandr-dev (>= 2:1.2.99) but it is not going to be installed
                 Depends: libxcursor-dev but it is not going to be installed
                 Depends: libxfixes-dev (>= 1:3.0.0-3) but it is not going to be installed
                 Depends: libxcomposite-dev (>= 1:0.2.0-3) but it is not going to be installed
                 Depends: libxdamage-dev (>= 1:1.0.1-3) but it is not going to be installed
                 Depends: libxml2-utils but it is not going to be installed
                 Recommends: debhelper but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
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.

以我以往的经验,pycharm可以做本地可视化,但有时会出错,这与pycharm版本有关还是与远程服务器有关。

© www.soinside.com 2019 - 2024. All rights reserved.