Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Debug Python Project in Visual Studio Code

Ways to Open a Command Palette

  1. Use Menu Menu -> View -> Command Palette....
  2. Use the shortcut Shift + Command + P (on macOS).

Command Palette

You can search for commands in the Command Palette, which makes things very convenient.

Run Tests or a Python File

  1. Open the Command Palette.
  2. Search for Python: Run in the Command Palette.
  3. Select the right command to run for your case.

Python: Run

Debug Tests or a Python File

  1. Open the Command Palette.
  2. Search for Python: Debug in the Command Palette.
  3. Select the right command to run for your case.

Python: Debug

Examplel of Debugging Configuration

launch.json for debugging Python code.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

Comments