5

I am running a cell in Jupyter notebook where an error is bound to occur after some time(usually hours). But even after this error occurs, I want the compiler to just move on to the next cell and run the remaining cells that I put in the queue to be run after this cell finishes.

I know exceptions might be able to do this, but I wanted to know if there was any other way specific to Python or Jupyter notebook that might do the trick.

Cell 1: Some code running # Error will occur here and stop the execution

Cell 2,3...,n: Some code # Code should still run after the error occurs in Cell 1

Thanks for any solutions. The help is appreciated.

Soham
  • 51
  • 3
  • 1
    Take a look on this: https://stackoverflow.com/questions/40110540/jupyter-magic-to-handle-notebook-exceptions – Masoud Jun 01 '19 at 01:09
  • Yeah, I already looked through this thread but I wasn't able to formulate a solution using the solution suggested there. Could you try to simplify what I should do in my case specifically? The reason I am asking is that it is mentioned there that exec is not able to access variables from other cells and I need to use the final values of variables in cell 1 in the cells after that. – Soham Jun 01 '19 at 09:13

1 Answers1

3

There's a Jupyter Notebook nbextensions extension called Runtools which allows you to run all cells and ignore errors with the shortcut Alt + F. See Installing jupyter_contrib_nbextensions on how to install nbextensions and enable extensions like Runtools.

mic
  • 990
  • 13
  • 27