vscode集成终端如何开启x11转发?

Posted

技术标签:

【中文标题】vscode集成终端如何开启x11转发?【英文标题】:How to enable x11 forwarding in vscode integrated terminal? 【发布时间】:2020-09-27 08:53:12 【问题描述】:

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

有什么建议吗?

【问题讨论】:

【参考方案1】:

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

在我的情况下,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"
            ,
        
    ]

【讨论】:

如果您想更深入地了解这可能会有所帮助,请记住 IP 应该是显示主机。 code.visualstudio.com/docs/python/debugging

以上是关于vscode集成终端如何开启x11转发?的主要内容,如果未能解决你的问题,请参考以下文章