Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code: How to launch an interactive python terminal while debugging

I have recently started using VS code for Python development. I am unable to figure out how to launch an interactive terminal while debugging, with the program state loaded-in . For example, consider the following code,

import numpy as np
A = np.array([1, 2, 3])
B = np.zeros()
C = A/B                  \\ <--- Breakpoint here

I want to set a breakpoint at C = A/B and as soon as the breakpoint hit, I want to launch an interactive terminal that holds the state of my program. So that I can play around with variables in the terminal.

This is simple and straightforward in other Python IDEs like Spyder and Pycharm. How do I do this with VS Code?

like image 419
exan Avatar asked Sep 07 '25 10:09

exan


1 Answers

There's the Python debugging console in VSCode. When your code stops on a breakpoint, you can click on the debug console button to open an interactive Python console with your current program state loaded in.

VSCode debugging screen - Microsoft Docs

like image 77
Rafael de Bem Avatar answered Sep 10 '25 00:09

Rafael de Bem