qt.qpa.xcb: could not connect to displayerror while using OpenCV on ec2 ubuntu server 20.0

Viewed 1886

I am trying to run Tesseract Ocr code as mentioned here https://www.pyimagesearch.com/2018/09/17/opencv-ocr-and-text-recognition-with-tesseract/ on ec2 ubuntu server 20.0.

I am facing an error on:

cv2.imshow("Text Detection", output)

The error is as follows:

qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.8/dist-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, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc.

Aborted (core dumped)

I know this line of code would open a window to display the image of detected output ,but that window is not showing up.Please help with the error.

1 Answers

You got this error because there was no UI to open up a window and show the image.

A quick fix will be to save and download the image. And view locally.

Another way is to setup a XServer and enable X11 forwarding via SSH.

Related