Setting up Python remote debugging in VSCode

前端 未结 2 1735
南笙
南笙 2021-02-06 15:34

I am having my remote(ubuntu 16.04) drive mounted on my local system(ubuntu 16.04) so that I can edit the source files by opening them in vscode.

Also, in the integrated

2条回答
  •  时光说笑
    2021-02-06 16:18

    You need to put the remote ip address in both ptvsd.enable_attach("my_secret", address = ('remote_ip_address', 3000)) and in launch.json:

    {
      "name": "Attach (Remote Debug)",
      "type": "python",
      "request": "attach",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/home/user1/scripts/",
      "port": 3000,
      "secret": "my_secret",
      "host": "remote_ip_address" 
    }
    

    You also need to change the remoteRoot value to the path of the directory where the script is located in the remote machine (e.g. /home/user1/scripts/).

    Finally, open an ssh connection: ssh -L 3000:localhost:3000, run your script in the remote machine and attach the debugger in the local machine.

提交回复
热议问题