Skip to content

breakpoint() not working #897

Open
Open

Description

@fcollonval

Using a fresh install of Jupyter Lab my usual breakpoint() to invoke the debugger in a Notebook is skipped (see screenshot). Using import pdb; pdb.set_trace() instead invokes pdb as expected.

I was expecting (am I wrong?) that a call to breakpoint() in a cell would invoke pdb.

This is using a fresh conda install of Jupyter Lab this morning, no reconfiguration of the environment has occurred.

Description

image

Reproduce

I've created a fresh minimal environment:

$ conda create -n tmp_env python=3.8 jupyterlab

$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.4.3
qtconsole        : not installed
ipython          : 7.27.0
ipykernel        : 6.3.1
jupyter client   : 7.0.2
jupyter lab      : 3.1.10
nbconvert        : 6.1.0
ipywidgets       : not installed
nbformat         : 5.1.3
traitlets        : 5.1.0

and then I run jupyter lab and try to call breakpoint() as noted in the screenshot above.

I used jupyter lab --debug and scanned the output, nothing looked amiss (but there's a lot and I'm not sure what to look for) - I can attach a copy if needed?

I noticed this originally in a second more complex environment (also built today, making me think this is a library update issue somewhere) and I made the above simple environment to try to narrow things down, but the issue remains.

Environment

Linux Cinnamon using Anaconda with Firefox, the OS is all up to date.

$ inxi -b
System:    Host: ian-XPS-15-9550 Kernel: 5.4.0-77-generic x86_64 bits: 64 Desktop: Cinnamon 4.8.6 
           Distro: Linux Mint 20.1 Ulyssa 
Machine:   Type: Laptop System: Dell product: XPS 15 9550 v: N/A serial: <superuser/root required> 
           Mobo: Dell model: 0N7TVV v: A00 serial: <superuser/root required> UEFI [Legacy]: Dell v: 1.9.0 date: 10/11/2018

originally posted by @ianozsvald on jupyterlab/jupyterlab#10996

Activity

  1. javier-hm commented on May 6, 2022

    @javier-hm

    Hi! I have Jupiter Notebook version 6.4.11. In my case I can't run breakpoint on my notebook.

  2. mdengler commented on Jun 9, 2022

    @mdengler

    Can confirm it's still broken.

    image

    $ poetry run jupyter --version
    Selected Jupyter core packages...
    IPython          : 8.2.0
    ipykernel        : 6.13.0
    ipywidgets       : 7.7.0
    jupyter_client   : 7.2.2
    jupyter_core     : 4.10.0
    jupyter_server   : 1.16.0
    jupyterlab       : 3.3.4
    nbclient         : 0.5.13
    nbconvert        : 6.5.0
    nbformat         : 5.3.0
    notebook         : 6.4.11
    qtconsole        : 5.3.0
    traitlets        : 5.1.1
    
    $ cat /etc/fedora-release
    Fedora release 35 (Thirty Five)
    
    $ uname -a
    Linux cdcx4 5.17.11-200.fc35.x86_64 #1 SMP PREEMPT Wed May 25 14:56:43 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    
  3. Tim-K-DFW commented on Dec 16, 2022

    @Tim-K-DFW

    Any updates on this? The only way I found that works is

    import sys
    
    def override_sys_breakpoint(frame=None):
        from IPython.core.debugger import set_trace
        set_trace(frame=frame)
    
    sys.breakpointhook = override_sys_breakpoint
    

    (ipython 7.34.0; jupyterlab 3.2.0)

    It worked fine before, so I hope this is just a bug/regression, not a deliberate decision?

  4. kerrickstaley commented on Jun 14, 2023

    @kerrickstaley

    This is caused by debugpy. If you run

    import pdb; pdb.runeval('breakpoint()')
    

    you will see that it steps into debugpy code. If you step a few more times you'll see that it eventually hits the line

        327     if not is_client_connected():
        328         log.info("breakpoint() ignored - debugger not attached")
    --> 329         return
    

    and so breakpoint() will exit without doing anything.

    You can work-around this issue by running
    python3 -m pip uninstall debugpy
    in the terminal.

    @JohanMabille you added the ipykernel debugpy integration; do you know what needs to be done to get breakpoint() to work out-of-the-box?

  5. astrojuanlu commented on Sep 26, 2023

    @astrojuanlu

    This was very puzzling indeed, although difficult to say if it's a feature or a bug...

    If breakpoint() is supposed to be active only when the debugger is enabled, maybe emitting a warning would be better than silently passing.

  6. JohanMabille commented on Sep 26, 2023

    @JohanMabille
    Contributor

    Sorry for the late reply, I missed your ping @kerrickstaley ! I think you can execute the following code in a notebook cell to start debugpy:

    import debugpy
    debugpy.listen(("localhost", 5678)) # or debugpy.listen(5678)

    Not 100% sure (this is a bit far to be honest), but this should be enough to setup breakpoints

  7. kerrickstaley commented on Sep 28, 2023

    @kerrickstaley

    I think there's a bug here that should be fixed. When you install debugpy [1], it silently breaks the behavior of the breakpoint() function when run in a Jupyter notebook. I think that breakpoint() should always launch pdb unless the user configures it to do something else.

    [1] Which in my case I didn't do deliberately; I think it was a dependency of something else I installed.

  8. mdengler commented on Sep 28, 2023

    @mdengler

    [...] breakpoint() is supposed to be active only when the debugger is enabled [...]

    Not sure where this statement comes from. breakpoint() is not for use when the debugger is enabled;breakpoint() is the "universal API for entering the debugger" (emphasis mine). Breaking it -- that is, preventing a call to breakpoint() from "entering the debugger" -- is definitely a bug, nor is the expected behavior of breakpoint() to do nothing.

  9. zhanwenchen commented on Feb 13, 2024

    @zhanwenchen

    Any update on this issue? It's been 4 years.

  10. pascal-mueller commented on Aug 17, 2024

    @pascal-mueller

    It's been 4.5 years now. :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions