如何解决VS Code:QT 无法连接到显示
语言:python==3.8.5
平台:Anaconda==4.9.2
操作系统:Ubuntu 20.10
包:opencv-contrib-python==4.5.1.48
IDE:VS Code 2020
执行 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)
使用 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,vnc.
Aborted (core dumped)
仅当我在 vs code 终端中运行脚本时才会出现此问题。该脚本在 ubuntu-terminal 中执行时没有错误。
对此问题的一些帮助将不胜感激。谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。