I'm using Jupyter (IPython) notebook, where pdb / ipdb runs fine, except for one problem: If I accidentally run the same cell that my pdb is in while in pdb mode, the output disappears, the entire notebook gets stuck and I can't run any more commands. I also tried interrupting or restarting the kernel; doesn't work. My only option is to shut down the notebook, and restart it.
Does anyone else experience this problem / know of a solution? Very annoying for me to have to restart the notebook every time I make this mistake.
Here are screenshots of the problem. Below I'm in pdb mode as expected:
If I then (accidentally) run the same cell my pdb is in, the notebook gets stuck trying to run that cell, and won't run anything else (like the cell below).
'Kernel -> Interrupt' (or Restart) to exit out of the pdb loop. You should q(uit) pdb if you want your kernel to continue running before running another cell.
If you enter pdb interactive mode there is no way to return to ipdb or ipython. The proper way to exit is by using ctrl-d .
Try disabling any browser extensions and/or any Jupyter extensions you have installed. Some internet security software can interfere with Jupyter. If you have security software, try turning it off temporarily, and look in the settings for a more long-term solution.
You can use IPython. display. clear_output to clear the output of a cell.
In newer versions of Jupyter (mine is 6.1.4
), pressing the "Interrupt kernel" button solves the problem (and you keep all your variables and your python session):
Pressing the button after you re-run the cell yielding the break point, you again get the pdb
console printed to the output of the cell where you then can interact with pdb
again. It seems that the "Interrupt kernel" works like a Keyboard interrupt, forcing the output cell to refresh.
Pressing i
twice after the re-run has the same effect (see also this post).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With