- Paste the snippet below in a normal(code) cell,
- execute it (hit [Ctrl + Enter]), and
- Save the notebook.
The next time you (re)load it,
all cells will run and a checkpoint will be saved with their refreshed outputs.
%%html
<script>
// AUTORUN ALL CELLS ON NOTEBOOK-LOAD!
require(
['base/js/namespace', 'jquery'],
function(jupyter, $) {
$(jupyter.events).on("kernel_ready.Kernel", function () {
console.log("Auto-running all cells-below...");
jupyter.actions.call('jupyter-notebook:run-all-cells-below');
jupyter.actions.call('jupyter-notebook:save-notebook');
});
}
);
</script>
Note that if you clear the output of the above cell, you have to repeat steps 2 and 3.
TIP
You may consider these more appropriate solutions for what you are probably trying to achieve:
- Jupyer Thebe: embed code-snippets in static pages communicating with ipython-kernels backends.
- nteract: Build Electron-based applications from notebooks.
- Dashboards: The "official"efforts to allow to pre-configure a grid of notebook-cell outputs ("dashboards"), package and serve them as standalone web apps.
You can find a summary of the situation in this article.
Controversy
Similar questions has been asked before in other sites, but in this googlegroup thread, someone submitted a solution, and the group moderator erased it(!), obviously to preserve life on earth :-)
So, be careful with it!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…