How To Debug Python Code In Visual Studio Code (VSCode)

preview_player
Показать описание
How To Debug Python Code In Visual Studio Code (VSCode)

1. **Install Python Extension**: If you haven't already, install the Python extension for VS Code. You can do this from the Extensions view by searching for "Python."

2. **Open Your Python Project**: Open the Python project you want to debug in VS Code.

3. **Create a Debug Configuration**:
- Click on the gear icon in the Activity Bar on the side or use `Ctrl + Shift + D` to open the Run and Debug sidebar.

4. **Select Python Configuration**: In the list of available configurations, choose "Python."

5. **Configure Debug Settings**:

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

You can modify this configuration as needed.

6. **Set Breakpoints**:
- Open the Python file you want to debug.
- Click in the gutter next to the line number to set a breakpoint. Alternatively, you can use the `F9` key.

7. **Start Debugging**:
- Click the green "Start Debugging" button in the Run and Debug sidebar or press `F5`. This will start debugging your Python script.

8. **Debugging Actions**:
- While debugging, you can use common debugging actions like step into (`F11`), step over (`F10`), continue (`F5`), and stop debugging (`Shift + F5`).

9. **Inspect Variables**:
- Use the Variables panel to inspect the values of variables in your code.

10. **Watch Expressions**:
- You can add watch expressions to monitor specific variables or expressions during debugging.

11. **Interactive Debugging**:
- VS Code provides an interactive console in the Debug Console tab where you can run Python commands while debugging.

12. **Finish Debugging**:
- When you're done debugging, you can stop the debugger by clicking the red square "Stop" button or using `Shift + F5`.

#Python #Debugging #VisualStudioCode #VSCode #ProgrammingTutorial #DebuggingTutorial #CodeEditor #Breakpoints #Variables #Expressions #Runtime #ConsolePrinting #BeginnerFriendly #ProgrammingEducation

#howtodebugpython
#howtodebugpythoninvscode
#howtodebugpythoninvisualstudiocode
#debugging
#debugpythoncode
#debugpythoncodeinvscode
#debugpythoninide

like ,share ,subscribe & press on bell icon.

Рекомендации по теме
Комментарии
Автор

Thank you! I learnt a lot how to debug python code in visual studio code.

BreakingTrendsToday
Автор

VSCode keeps on "upgrading". I wonder if this is out of date now.

feraudyh
Автор

This is a very good and informative video, it helped me to understand how to debug python code in visual studio code. Thanks for creating this video.

TheReviewZone-TRZ
Автор

useless video you should have explained the process of what you are doing while debugging.

TheAAAKII