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

Closed

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

Activity

  1. rchiodo commented on Jun 15, 2026

    @rchiodo
    Contributor

    Sorry but this is by design. The file has been modified so it doesn't match. You have to restart the kernel in order to reload the file into the process.

    Although I thought we indicated this to VS code by saying the source doesn't match.

    Well anyway, there's no way for this to work because the file has changed and you need to reload it into the kernel. The kernel is still using the old file.

  2. Gazoo101 commented on Jun 17, 2026

    @Gazoo101
    Author

    A shame. It'd be wonderful to not have to restart the kernel each time as modifying external .py files while building in/around a Jupyter file is super useful.

    Regardless, I much appreciate you taking the time to confirm this behavior is 'as intended'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions