I have a problem when the output from a notebook is really long and it's saved into the notebook, any time I want to open this particular notebook again the browser crashes and can't display correctly.
To fix this I have to open it with a text editor and delete all output from that cell causing the problem.
I wonder if there is a way to clean all output from the notebook so one can open it again without problem. I want to delete all output since deleting a specific one seems more troublesome.
解决方案
--ClearOutputPreprocessor.enabled=True
There is now a built-in command line option to do it:
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace Notebook.ipynb
Or to another file called NotebookNoOut.ipynb:
jupyter nbconvert --ClearOutputPreprocessor.enabled=True \
--to notebook --output=NotebookNoOut Notebook.ipynb
jupyter nbconvert --help also documents a --clear-output option, but for some reason it did not work.
Tested in Jupyter 4.4.0, notebook==5.7.6.