Language : python==3.8.5
Platform : Anaconda==4.9.2
Operating System : Ubuntu 20.10
Package : opencv-contrib-python==4.5.1.48
IDE : VS Code 2020
Got this error while executing cv2.imshow('Final', src_img)
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/ubuntu/anaconda3/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, eglfs, minimal, minimalegl, offscreen, vnc.
Aborted (core dumped)
Executing with QT_DEBUG_PLUGIN=1 script.py
QFactoryLoader::QFactoryLoader() looking at "/home/bas/anaconda3/plugins/platforms/libqxcb.so"
Found metadata in lib /home/bas/anaconda3/plugins/platforms/libqxcb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"xcb"
]
},
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 329991
}
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/bas/anaconda3/bin/platforms" ...
loaded library "/home/bas/anaconda3/lib/python3.8/site-packages/cv2/qt/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/bas/anaconda3/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, eglfs, minimal, minimalegl, offscreen, vnc.
Aborted (core dumped)
Getting this problem only if I run the script in vs code terminal. The script runs without errors when executed in ubuntu-terminal.
Some help with this issue would be appreciated. Thanks