Within pdb
, I'm using the interact command to enter interactive mode (documentation).
This gives me an InteractiveConsole within pdb
(which I need in order to do list comprehension).
From within a Jupyter Notebook, how do I leave interactive mode without exiting the debugger entirely?
This question is the exact same question but the solutions only work from the terminal.
quit()
returns NameError: name 'quit' is not defined
I can do import sys; sys.exit()
, but that exits the debugger entirely, meaning I have to start from scratch.
On a related note, if you want to exit the debugger entirely you just press q then enter.
'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.
You can write exit() to quit debug mode. Show activity on this post. you can use "ctrl+d" to delete the cell.. I just successfully used exit() in my Jupyter (formerly iPython) notebook (on a Mac) to get out of a debug session.
Pausing or Stopping the Debugger At this point you can click the Start button to continue running the script, click the Step button to execute the highlighted line of code, or execute additional Python commands. To stop debugging the script, click the Stop button or press the Esc key.
Here is a solution similar to triccare's which doesn't require Emacs.
Run this command on Linux:
echo '\x04' | xclip -selection clipboard
or this command on macOS:
echo '\x04' | pbcopy
and then paste into PDB interactive prompt in Jupyter and press enter.
How this works: This puts the ASCII character 0x04, "END OF TRANSMISSION", onto your clipboard. This character is a "control character" that signals that there is no more input, which causes the PDB interactive session to end.
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