Notebook: Exiting interact mode in %%debug cell

Created on 9 May 2018  路  5Comments  路  Source: jupyter/notebook

If I start a debug session with %%debug at the start of a cell, and then drop into interactive mode with interact I can't find a way to get out of interactive mode. In pdb in the terminal ctrl-D does it, but that just offers to bookmark the page in chrome. Various combinations of exit/quit/exit()/q/etc just give NameError - not defined. import sys; sys.exit() kills the entire debug process.

Apologies if this is answered somewhere, but a fair amount of searching (e.g. https://stackoverflow.com/questions/45814503/how-to-properly-exit-ipdb-interactive-console-in-jupyter-notebook, https://stackoverflow.com/questions/47522316/exit-pdb-interactive-mode-from-jupyter-notebook) didn't turn up anything.

I'm using jupyter version 4.4.0

Most helpful comment

That's awesome, thank-you very much! I don't use emacs but a similar technique of getting ctrl-d into the clipboard and pasting it in works for me.

echo ^D | xclip -selection clipboard (where to get ^D I type ctrl-v ctrl-d) is what I did.

All 5 comments

I have an answer seen in the SO post 47522316, listed above. The answer given is not necessarily satisfactory, but works for me:

The only way I have been success is to copy/paste the Crtl-D character from another source. I use Emacs, so this is fairly easy, but any text editor that allows you to insert a Crtl-D into the document should work. Once inserted, use the standard copy/paste into the pdb interact field and hit RETURN or ENTER . This should get you out.

For Emacs, the long way is as follows, for demonstration purposes:

M-x insert char <RET> END OF TRANSMISSION <RET>

At this point you should see ^D in the buffer. At this point select the character and M-w or kill-ring-save to put it on the clipboard.

Then, change to the browser and make the interactive field active, and paste the character back. You will not see anything. Then hit RETURN or ENTER . This should/might get you out.

That's awesome, thank-you very much! I don't use emacs but a similar technique of getting ctrl-d into the clipboard and pasting it in works for me.

echo ^D | xclip -selection clipboard (where to get ^D I type ctrl-v ctrl-d) is what I did.

any better option? what you mention is not working to me.

Same issue, and I am using JupyterLab on windows with Chrome. I tried a Chrome extension to disable the Ctrl-D shortcut without success. Anybody aware of a workaround for windows?

Platform independent, though still rather clunky:

from pandas.io.clipboard import copy; copy("\x04")

Copies Ctrl-D to your clipboard, and the you can paste it and enter.

Was this page helpful?
0 / 5 - 0 ratings