`breakpoint` in a script does not invoke debugger in notebook


In python notebooks, I have used breakpoint in scripts to invoke the debugger within a notebook. However, something seems to have changed, and this is no longer the case.

A script such as shouldbreak.py containing the following:

def should_break():
    print('Before breakpoint')
    print('After breakpoint')

when run in a notebook, simply runs to completion:

In [1]: import shouldbreak
Before breakpoint
After breakpoint

This is on MACOS Catalina, running Python 3.9.7 and notebook server 6.4.5

Thank you for posting. I believe that this is related to changes in ipykernel which enable the graphical debugger in JupyterLab (see `breakpoint()` not working but `import pdb; pdb.set_trace()` works as expected · Issue #10996 · jupyterlab/jupyterlab · GitHub) could you please open an issue on GitHub - ipython/ipykernel: IPython Kernel for Jupyter for that?

1 Like

Will do! Thanks for the reply!

Solution for future searchers (like me):

In JupyterLab you have to Enable Debugger - the bug icon on the right side of the notebook’s top bar.


Without this the breakpoint() call is ignored.