read-only cells in ipython/jupyter notebook

@Richard Ackon’s answer requires adjustments for JupyterLab:

  1. Open the Property Inspector.

  2. Focus the cell you want to lock.

  3. Add the following lines to the Cell Metadata:

    {
        "trusted": true,
        "editable": false,
        "deletable": false
    }
    
  4. Click on the tick to save the metadata… Tadah!, your cell can’t be modified or deleted.

The Property Inspector comes built-in since JupyterLab 2.0 (note it was moved to the right sidebar by default in JupyterLab 3.0). For older JupyterLab versions you would need to modify the notebook file manually.

enter image description here

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)