Skip to content

Breakpoints in an external .py file works when a Kernel is freshly started, but any change to the py file breaks behavior #2036

Description

@Gazoo101

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

I create an .ipynb file:

%load_ext autoreload
%autoreload 2

from external import my_external_loop, some_other_function

my_external_loop()
some_other_function()

and a .py file with some external code.


def my_external_loop():

    for x in range(10):
        print(x)

    
    print("nroks")
    

    print("hello wurld")


def some_other_function():


    print("Guess who's coming to gorlack?")

When running 'debug cell' a breakpoint set in the .py file is hit as expected. Any change to the .py file causes the breakpoint no longer to be hit and if I instead break inside the jupyter cell (which still works) and enter into the external code by line-stepping via F11, the line execution is displayed as occuring at the top of the file, as opposed inside either of the functions.

Screenshot:

Image

VS Code Version

1.116.0

Jupyter Extension Version

v2025.9.1

Jupyter logs

Not sure how to enable this?

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions