Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use pdb (Python debugger) in Visual Studio Code IDE's debugger?

I always used pdb for Python debugging before. Recently, I start using Visual Studio Code.

It looks in Visual Studio Code debugger, if I set a breakpoint(), Visual Studio Code will show variables' value at stopped position in the left window and I have to control it by a GUI bar.

So in "integratedTerminal" or "externalTerminal", I have no control by command line which is shown here and there isn't a pdb prompt popup. I kind of feel this surprises me since it hijacks pure Python stuff.

So is there a way to have both, the variables watch window and pdb prompt control? Especially in "integratedTerminal" or "externalTerminal".

Below are files under folder .vscode,

File settings.json

{
    "python.pythonPath": "/Users/<USERNAME>/miniconda3/envs/<CONDA_ENV>/bin/python"
}

File launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Module",
            "type": "python",
            "python": "/Users/<USERNAME>/miniconda3/envs/<CONDA_ENV>/bin/python",
            "request": "launch",
            "program": "/Users/<USERNAME>/miniconda3/envs/<CONDA_ENV>/bin/<COMMAND>",
            "console": "integratedTerminal",
            "args": [
                "hello-world"
            ],
            "cwd": "${workspaceRoot}",
        }
    ]
}
like image 897
Ke Zhang Avatar asked May 01 '26 02:05

Ke Zhang


1 Answers

According to the information you described, when I use "breakpoint()" in the code, I click F5 to debug the code in Visual Studio Code. When the code stops, we can use the shortcut key Ctrl + Shift + ` to open a new terminal and enter the pdb interactive window. At this point, we can not only see the debug variable value, but also use the 'pdb' command:

Enter image description here

Update:

Enter image description here

like image 94
Jill Cheng Avatar answered May 03 '26 15:05

Jill Cheng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!