Kurosh
Kurosh

Reputation: 21

how to configure Vscode to debug Python using WSL?

I found the configuration for cpp (https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/Debugger/gdb/Windows%20Subsystem%20for%20Linux.md) and tried to change it for python debugging but it doesn't work. Any suggestion to make it work?

Upvotes: 2

Views: 11578

Answers (3)

Adam Cooper
Adam Cooper

Reputation: 8687

This is now supported and just requires installing the Microsoft Python extension and then to quote the documentation on remote debugging with WSL:

Once you've opened a folder in WSL, you can use VS Code's debugger in the same way you would when running the application locally. For example, if you select a launch configuration in launch.json and start debugging (F5), the application will start on remote host and attach the debugger to it.

See the debugging documentation for details on configuring VS Code's debugging features in .vscode/launch.json

Upvotes: 0

William
William

Reputation: 486

Beyond extensions installations, IDE_PROJECT_ROOTS environment variable also may affect the debugger. For usual WSL standalone python code debugging, making sure this variable is not set (or set to the location of the files) when the VS code is opened helps.

 For "step into" debugging of jupyter notebook having the python files path(s) as a part of IDE_PROJECT_ROOTS (for example export IDE_PROJECT_ROOTS="/tmp:/foo_pythonfilespath" set in .bashrc) will help to carry out "step into" python-code debugging in VSCode.

Upvotes: 0

Brett Cannon
Brett Cannon

Reputation: 16080

It should be mentioned that the Python extension for VS Code does not officially support WSL yet, but the enhancement request has been made and we do plan on supporting it.

Upvotes: 0

Related Questions