Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98994

Setting up Python remote debugging in VSCode

$
0
0

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 terminal I can ssh to remote system and run the program using remote python interpreter which is installed on virtual environment like:

$ssh username@remoteip    
$workon remotevirtualenv
(remotevirtualenv)$python source.py

I want to enable remote debugging so that if I run the debug/run the remote files, the vscode which is installed on my local system uses my remote python interpreter.

I went through the docs suggesting the use of ptvsd extension(which asks to have 2 copies of source files one on local, another one server) but I am not sure how to configure it in this scenario. Appreciate the help. Thanks.

Edit 1: As, I said I have gone through the docs but I am not clear how to configure in this scenario. e.g. docs say

  1. In the source code on both computers, add the following lines, replacing my_secret with the appropriate passphrase to authenticate remote debugging, and replacing address with the appropriate IP address (or localhost) and port number:
ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))

But I have only one copy of source file i.e. on remote system. I have just mounted it on my local file system. So, should I give my local ip address or it should be remote system ip and which port number should I use as I am having only one copy of source and hence ptvsd, how is it going to communicate. Also, in the configuration, what should I use for localRoot location and remoteRoot location.

 3. {
     "name": "Attach (Remote Debug)",
     "type": "python",
     "request": "attach",
     "localRoot": "${workspaceFolder}",
     "remoteRoot": "${workspaceFolder}",
     "port": 3000,
     "secret": "my_secret",
     "host": "localhost" 
 }

Edit: Thanks to remote development extension in VSCode, remote debugging is super easy now.


Viewing all articles
Browse latest Browse all 98994

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>