Suppose I executed all cells in a Jupyter Notebook, and want to interrupt the computation in the middle. How can I stop the execution of all cells?
"Kernel interrupt" only interrupts the execution of the current cell, but then immediately continues with all remaining cells. Instead, I do not want to execute all remaining cells after hitting "Kernel interrupt". How can I do that?
I am running version 4.2.3 with Python 3.5.2, packaged by conda-forge
To stop running a piece of code, press the stop button. To create new cells, use the plus (+) button in the toolbar or hit SHIFT+ENTER on the last cell in the Notebook.
Ctrl+C should break out of an infinite loop while a cell is running.
If you know it beforehand, where you want to stop (e.g have code below that takes long and doesn't need to be executed every run), you can add a
raise SystemExit("Stop right there!")
whereever you want to stop.
Everything below isn't executed, since an exception has been thrown and when using the SystemExit Exception no stacktrace is shown by default.
The kernel doesn't exit, so you can still execute everything by hand afterwards.
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