Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python debug adapter not being found in vscode - WSL:Ubuntu

I'm trying to debug a python script in vscode using the Remote WSL extension with Python 3.9.1.

When I start debugging mode(F5), the below message is immediately shown:

Couldn't find a debug adapter descriptor for debug type 'python' (extension might have failed to active)

The message offers me to Open launch.json, I still don't know what I have to change in my json file, below are my current settings:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "env": {
                "PYTHONPATH": "c:/<my_user_name>/projects",
            },
        }
    ]
}

What I have tried until now:

  • Re-installed Python extension and read the doc. However the doc does not help to solve the issue at all. These steps has been already suggest in another post here almost 3 years ago.
  • Reload vscode in order to reload the extensions, as the error shows an extensions might have failed to active. No success.
like image 273
asa Avatar asked Jan 28 '21 09:01

asa


People also ask

How do I enable Python debugger in Visual Studio code?

If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.

How do I run Python in debug mode in Terminal?

Directly use command python pdg-debug.py without -m pdb to run the code. The program will automatically break at the position of pdb. set_trace() and enter the pdb debugging environment. You can use the command p variable to view the variables or use the command c to continue to run.

Where is launch json in Vscode?

The launch. json file is located in a . vscode folder in your workspace (project root folder).


1 Answers

If you have VSCode, installed already before you could configure WSL, you could be facing this issue. Here's how I resolved it:

  1. To the bottom left corner of VSCode, you may find the environment choice. Natively, this corresponds to windows, you might have to switch this to Remote-WSL: New Window which will open VSCode in a new window. enter image description here

  2. In the debug tab of VSCode, you don't have to edit any configuration, except you need to define the location of your interpreter. In my case, I defined the location to be as my virtual environments' bin/ directory.

Good Luck!

like image 186
Sathyasarathi Gunasekaran Avatar answered Sep 21 '22 04:09

Sathyasarathi Gunasekaran