When using Jupyter notebook, outputs (include error messages) from executing a cell can be useful and so I'd like to freeze the cell alone with its outputs, or in another word, to inactivate the cell in order to keep the output.
Is this doable?
When using Jupyter notebook, outputs (include error messages) from executing a cell can be useful and so I'd like to freeze the cell alone with its outputs, or in another word, to inactivate the cell in order to keep the output.
Is this doable?
This freezes the cell, but not the output:
Open the notebook in an editor.
Look for the cell you want to lock.
Add the following lines to the metadata of the cell:
"metadata": {
"trusted": true,
"editable": false,
"deletable": false
}
Save and reload the notebook in Jupyter and... Tadah!, your cell can't be modified or deleted.
Unfortunately, the outputs can still be cleared by intentionally selecting that option in the menu bar (Edit
> Clear Ouputs
). Of course that can only happen if you DO WANT to clear the outputs and not just update them by running the cell.
Historically, such a feature has not been available in native Jupyter.
However, you might try a Jupyter extension called "Runtools" available that displays a button that should run all cells and ignore exceptions.
There is a now an extension called Freeze
in the default suite of nbextensions.
pip install jupyter_contrib_nbextensions
and open Edit/nbextensions config
from any notebook to enable freeze.