VSCode 从远程服务器绘图问题:qt.qpa.xcb:无法连接到显示器

VSCode plotting from remote server issue: qt.qpa.xcb: could not connect to display

来自本地 VSCode 的请求是这样的:

Host XXX.XX.XX.XXX
  HostName XXX.XX.XX.XXX
  ForwardX11Trusted yes
  IdentityFile ~/.ssh/Key.pem
  User ubuntu

在服务器上,我在 /etc/ssh/sshd_config 文件

中启用了 X11Forwarding yes

我仍然收到此错误

qt.qpa.xcb: could not connect to display :0.0 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.

注意:我正在使用 VSCode 的集成终端用于 运行 一个 python 脚本。

只需在VSC终端添加命令:export DISPLAY=:0