Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to CTRL+C in IPython Notebook in Firefox to break cells that are running?

I've started to use the IPython Notebook and am enjoying it. Sometimes, I write buggy code that takes massive memory requirements or has an infinite loop. I find the "interrupt kernel" option sluggish or unreliable, and sometimes I have to restart the kernel, losing everything in memory.

I also sometimes write scripts that cause OS X to run out of memory, and I have to do a hard reboot. I'm not 100% sure, but when I've written bugs like this before and ran Python in the terminal, I can usually CTRL+C my scripts.

I am using the Anaconda distribution of IPython notebook with Firefox on Mac OS X.

like image 359
wwwilliam Avatar asked Jul 10 '13 01:07

wwwilliam


People also ask

How do you stop a cell from running in Jupyter Notebook?

Stopping a process or restarting a Jupyter Notebook To interrupt a cell execution, you can click the ■ “stop” button in the ribbon above the notebook, or select “Interrupt Kernel” from the Kernel menue.

How do you cut cells in Jupyter Notebook?

“delete a cell in jupyter notebook” Code Answer'sD+D(press the key twice when you are in command mode) to delete the selected cell.

What keyboard shortcut can you press to execute a cell in Jupyter?

Alt + Enter run the current cell, insert below.

What is used to run system commands from IPython?

IPython bridges this gap, and gives you a syntax for executing shell commands directly from within the IPython terminal. The magic happens with the exclamation point: anything appearing after ! on a line will be executed not by the Python kernel, but by the system command-line.


2 Answers

You can press I twice to interrupt the kernel.

This only works if you're in Command mode. If not already enabled, press Esc to enable it.

like image 54
cutie Avatar answered Sep 19 '22 18:09

cutie


I could be wrong, but I'm pretty sure that the "interrupt kernel" button just sends a SIGINT signal to the code that you're currently running (this idea is supported by Fernando's comment here), which is the same thing that hitting CTRL+C would do. Some processes within python handle SIGINTs more abruptly than others.

If you desperately need to stop something that is running in iPython Notebook and you started iPython Notebook from a terminal, you can hit CTRL+C twice in that terminal to interrupt the entire iPython Notebook server. This will stop iPython Notebook alltogether, which means it won't be possible to restart or save your work, so this is obviously not a great solution (you need to hit CTRL+C twice because it's a safety feature so that people don't do it by accident). In case of emergency, however, it generally kills the process more quickly than the "interrupt kernel" button.

like image 25
seaotternerd Avatar answered Sep 18 '22 18:09

seaotternerd