通过SSH为远程Python解释器配置Visual Studio代码

Ουι*_*ευα 5 python configuration remote-debugging ssh-tunnel visual-studio-code

我有一个带有ArchLinux和Python的Vagrant框,该框针对每个项目使用虚拟环境(通过使用特定的Python版本)。我希望配置VSC来运行/调试这些Python项目。我已经挂载了包含我的项目的目录(使用sshfs),所以我不必担心同步。

使用PyCharm时,配置仅在其IDE中。如何使用SSH为VSC配置它?使用Python需要其他哪些插件?

提前致谢。

PS1:PyCharm是一个很棒的工具,但是它占用大量资源,RAM接近1GB。

PS2:我已经阅读了这篇文章,但是对我来说还不清楚,一个例子更有用。

Ουι*_*ευα 5

使用 Pydev 和 RSE 服务器在远程 Linux 机器上定义远程解释器一文确实很有用,现在看起来很明显。这是我使用自己的系统配置的解决方法:

第 1 步:安装远程主文件夹。

$ sshfs -o password_stdin,transform_symlinks vagrant@localhost:/home/vagrant ~/Vagrant/archi02/Remote/ -p 2222 <<< "your_vagrant_password"
Run Code Online (Sandbox Code Playgroud)

第 2 步:使用 VSC 打开项目文件夹。

~/Vagrant/archi02/Remote/Projects/Python_3_7_2/QuickPythonBook/
Run Code Online (Sandbox Code Playgroud)

步骤 3 :为远程 Python 和 linter配置“ settings.json ”(来自WorkSpace 设置)。

{
    "python.pythonPath": "~/Vagrant/archi02/Remote/Projects/Python_3_7_2/QuickPythonBook/ve_qpb/bin/python3.7",
    "python.linting.pylintEnabled": true,
    "python.linting.pylintPath": "pylint"
}
Run Code Online (Sandbox Code Playgroud)

第 4 步:享受编程的乐趣。不客气。