exan
exan

Reputation: 3925

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?

Upvotes: 24

Views: 21639

Answers (5)

Vincent
Vincent

Reputation: 109

control+shift+Y (refer dash line in the image below)

View debug console

vscode version 1.86

Upvotes: 1

Xgk
Xgk

Reputation: 41

I faced the same issue. The reason I could not find the debug console was that it was hidden. From the explorer tab, click on the top right three buttons (...) and check the debug console.

Upvotes: 3

Rafael de Bem
Rafael de Bem

Reputation: 828

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

Upvotes: 22

azizbro
azizbro

Reputation: 4240

Do you mean the debug console tab? It's usually a tab on the bottom of the VS Code screen. enter image description here

Here is a video where it shows how to debug a server written in python and goes over the code using debug console: https://youtu.be/O2Skmwns6o8?t=424

Upvotes: 3

Someone2
Someone2

Reputation: 495

This Topic bugged me too, so I opened a feature request, where someone pointed the Debug-Console out which lets you interact with python at the point, where you're debugging.

Upvotes: 4

Related Questions