如何从 Linux 终端清除 Jupyter Notebook 在所有单元格中的输出? [英] How to clear Jupyter Notebook's output in all cells from the Linux terminal?
问题描述
当笔记本的输出很长并且保存到笔记本中时,我遇到了问题,每当我想再次打开这个特定的笔记本时,浏览器都会崩溃并且无法正确显示.
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.
推荐答案
nbconvert 6.0 应该修复 --clear-output
该选项之前已被破坏很长时间,带有合并补丁的错误报告:https://github.com/jupyter/nbconvert/issues/822
The option had been broken for a long time previously, bug report with merged patch: https://github.com/jupyter/nbconvert/issues/822
应用于就地操作:
jupyter nbconvert --clear-output --inplace my_notebook.ipynb
或者保存到另一个名为 my_notebook_no_out.ipynb
的文件:
Or to save to another file called my_notebook_no_out.ipynb
:
jupyter nbconvert --clear-output
--to notebook --output=my_notebook_no_out my_notebook.ipynb
这引起了我的注意 哈罗德在评论中.
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 中测试.
Tested in Jupyter 4.4.0, notebook==5.7.6.
这篇关于如何从 Linux 终端清除 Jupyter Notebook 在所有单元格中的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!