如何在vscode集成终端中启用x11转发?

问题描述

X11转发在ubuntu的终端上工作正常。但是如果我尝试从VSCode终端中的远程运行任何GUI,它将显示: cannot connect to X server

有什么建议吗?

解决方法

我使用菜单栏runrun without debugging选项找到了一种解决方案。 只是我们需要配置launch.json文件,并使用此命令ssh -Y -i ~/.ssh/Key.pem username@server从客户端PC打开终端。

在我的情况下,launch.json如下所示:

{
    "version": "0.2.0","configurations": [
        {
            "name": "Python: Current File","type": "python","request": "launch","program": "${file}","args": ["--target","dataset","--output","dataset_softmax","--nChannel","32","--minLabels","8","--filetype","png"],"console": "integratedTerminal","env": {
                "DISPLAY": "localhost:10.0"
            },}
    ]
}