供个人纪录用
配置说明
环境:pytorch 1.9.0 + torchvision 0.10.0
工具:VScode
系统:ubuntu20.04.1
错误示例
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/*****/miniconda3/envs/******/lib/python3.9/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.`
解决办法
第一步:安装远程ssh软件MobaXterm
第二步:连接到服务器,如图
第三步:
输入*echo $DISPLAY
*得到
第四步:在MobaXterm输入xclock,如有时钟,说明显示面板无问题
第五步:在VScode终端命令行输入
export DISPLAY=localhost:10.0
再跑程序这时候就不会报错了
总结
出现这个报错的主要原因是由于服务器上没有安装可显示图形化界面的后端,用这个办法也算是可以解决了