Step into only works during the first run when debugging through interactive
See original GitHub issueApplies To
- Notebooks (.ipynb files)
- Interactive Window and/or Cell Scripts (.py files with #%% markers)
What happened?
The contents of test.py
:
# %%
import numpy
print(numpy.__version__)
Also:
- I set up a breakpoint at
import numpy
intest.py
above. - I have
"jupyter.debugJustMyCode": false
in the settings. - I run VS Code under Windows. I connect to a remote, which has Ubuntu. (Local Extension: Remote - SSH v0.80.0)
First run:
- I click “Debug Cell”. The debugger pauses in a finally-clause in
interactiveshell.py
(probably an uncaught exception) - I press F5 (Continue) to step out of
interactiveshell.py
. The debugger points atimport numpy
. - I press F11 (Step in) to step into the import statement. As expected, the editor opens
__init__.py
of the module, and I can trace the execution. - I stop the debugger
Subsequent runs:
- [as above]
- [as above]
- I press F11 (Step in) to step into the import statement. The unexpected happens: instead of stepping into
__init__.py
, I find the debugger atinteractiveshell.py:3457
:exec(code_obj, self.user_global_ns, self.user_ns)
After I click “Restart” in the interactive window, the expected behaviour restores for the following run, after which the bug comes back.
If when stepped in __init.py__
I set a breakpoint there, then this breakpoint works in first runs, but is ignored in subsequent runs.
VS Code Version
Version: 1.67.0-insider (system setup) Commit: a3d53f76790d8c88f835afe85225ff6442703409 Date: 2022-04-07T05:15:43.863Z Electron: 17.3.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Windows_NT x64 10.0.19042
Jupyter Extension Version
v1.0.6
Jupyter logs
https://gist.github.com/avm19/201a983fb65ebbf543a2641b0030776d
Coding Language and Runtime Version
Python 3.7.7
Language Extension Version (if applicable)
v2022.5.10971003
Anaconda Version (if applicable)
conda 4.11.0
Running Jupyter locally or remotely?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Navigate through code by using the Visual Studio debugger
While debugging, open the Call Stack window by selecting Debug > Windows > Call Stack. In the Call Stack window, right-click a function...
Read more >Debugging Python in VSCode - 03 - Step Into and Step Out
This video is part of my comprehensive 48+ hour Python course available on Udemy:https://www.udemy.com/course/learn- to -code-with-python/?
Read more >Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >22 Debugging | Advanced R - Hadley Wickham
22.4.1 browser() commands · Next, n : executes the next step in the function. · Step into, or s : works like next,...
Read more >In Pycharm How to load code to interactive debugger?
To execute the selection in a debugger console, you first need to have the debugger running. You need to run a script using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The not stepping into
__init__.py
sounds more like the design of how packages work. Once a package is loaded into a python process it doesn’t run__init__.py
again.This has some more information: https://docs.python.org/3/tutorial/modules.html#tut-packages
So in this case if you debug a normal python file, you’re starting a python process every time. You’d expect to be able to debug
__init__.py
each time.If you debug from a kernel, it should only step into that file once, the first time the package is loaded into the kernel.
My bad, thanks for explaining!