pythonqtvisual-studio-codex11x11-forwarding

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


Request from my local VSCode is something look like this:

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

On the server, I enabled X11Forwarding yes in /etc/ssh/sshd_config file

Still, I am getting this error

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.

Note: I am using the integrated terminal of VSCode for running a python script.


Solution

  • Just add command in VSC terminal: export DISPLAY=:0

    Solution