5

I have my '.py' file, and I'm running its functions on the Python Interactive Window (the notebook-like feature of VSCODE). All the variables and functions are stored only in this Jupyter environment. They're not even accessible on the terminal.

Img that shows the variables on my Jupyter env

When I click "Debug Cell" (as you see on the img), it starts debugging using the Jupyter Environment, with all variables, but it doesn't stop on the breakpoints I've put. Like it doesn't get linked with VSCODE.

If I type F5 or click on "Run and Debug", it starts the Debug Session running the entire .py file, which is not what I want.

In this case, it can access the breakpoints, but not my variables.

I just want to debug a specific part of my code using the variables that I have already created. I must have been missing something really simple.

The only answer I can find on the internet is "you should create a launch.json file", but it doesn't fix my situation.

Does anyone know what I'm missing?

1 Answer 1

2

When I click "Debug Cell" in the python file, it executes the result in the "Interactive" window and can stay at the breakpoint I set, and I can also see the value of the variable executed in the code in the "Interactive" window :

enter image description here

Since the debugging function of python code and "Interactive" function are provided by the python extension, and the kernel function of Jupyter also depends on the Jupyter extension, please try to reinstall these two extensions and reload VS Code.

My environment:

VS Code: 1.53.1 (user setup)

python: 3.9.1

VS Code extensions: Python(2021.1.502429796); Jupyter(2020.12.414227052); Pylance(2021.2.2).

OS: Windows_NT x64 10.0.19041

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Jill, thanks for the answer. Actually, it does stop on the breakpoints, as you said. But when I click 'Step Into', it behaves differently depending on the function I'm stepping into. In some functions, it just goes to the code, as expected. In other functions, it opens another tab with the title "<ipython-input-15-2027ded5d38c>" and executes the code in there, like it's on memory or something. In that case, It doesn't stop on any breakpoints in this other tab. Both functions were properly loaded. I don't know what may be causing this different behavior. Do you have any idea?
@ Henrique Cardoso -What is the "<ipython-input-15-2027ded5d38c>"? When we call other modules or methods in the code, debugging will enter the called file. Could you please provide an example that can minimize the recurrence of the problem you encounter?
I think I just discovered a bug, but I couldn't reproduce it yet. Imagine I can't step into the function 'example1()', (because it opens ipython-input etc). I just discovered that after I click "Debug Cell" on example1()'s cell, just to run it inside the debugger, the 'Step Into' works as it should. It's like this function was loaded on Python but not on the VS Code Debug Extension. I don't know why it happened but at least now I know how to fix it. I'm gonna mark your answer as a solution. Thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.