Is there a way to mark a cell in the ipython notebook readonly using the json format in the ipynb file? (E.g., a cell attribute \"readonly\":false
or some such.) If
@Richard Ackon's answer is more direct, but DOES NOT WORK in Jupyter Lab:
The problem is that those menus and options are not present there.
A different (but not so efficient) alternative:
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.
Source