Keep Jupyter notebook running after closing browser tab

Florents Tselai picture Florents Tselai · Sep 12, 2015 · Viewed 24.1k times · Source

I use Jupyter Notebook to run a series of experiments that take some time. Certain cells take way too much time to execute so it's normal that I'd like to close the browser tab and come back later. But when I do the kernel interrupts running.

I guess there is a workaround for this but I can't find it

Answer

Seb picture Seb · Jun 15, 2017

The simplest workaround to this seems to be the built-in cell magic %%capture:

%%capture output
# Time-consuming code here

Save, close tab, come back later. The output is now stored in the output variable:

output.show()

This will show all interim print results as well as the plain or rich output cell.