当笔记本的输出非常长并且保存到笔记本中时,我遇到了一个问题,每当我想再次打开这个特定的笔记本时,浏览器就会崩溃并且无法正确显示。
要解决此问题,我必须使用文本编辑器打开它并删除导致该问题的单元格中的所有输出。
我想知道是否有一种方法可以清除笔记本中的所有输出,以便可以毫无问题地再次打开它。我想删除所有输出,因为删除特定输出似乎更麻烦。
最佳答案
nbconvert 6.0 应该修复 --clear-output
该选项之前已经被破坏了很长时间,带有合并补丁的错误报告:https://github.com/jupyter/nbconvert/issues/822
用法应该用于就地操作:
jupyter nbconvert --clear-output --inplace my_notebook.ipynb
或者保存到另一个名为 my_notebook_no_out.ipynb
的文件:
jupyter nbconvert --clear-output \
--to notebook --output=my_notebook_no_out my_notebook.ipynb
这引起了我的注意by Harold in the comments .
在 nbconvert 6.0 之前:--ClearOutputPreprocessor.enabled=True
用法与--clear-output
相同:
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace my_notebook.ipynb
jupyter nbconvert --ClearOutputPreprocessor.enabled=True \
--to notebook --output=my_notebook_no_out my_notebook.ipynb
在 Jupyter 4.4.0 中测试,notebook==5.7.6。
关于jupyter-notebook - 如何从 Linux 终端清除所有单元格中的 Jupyter Notebook 输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28908319/