问题描述
当笔记本的输出确实很长并且保存到笔记本中时,我有一个问题,每次我想再次打开该特定笔记本时,浏览器就会崩溃并且无法正确显示.
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
--ClearOutputPreprocessor.enabled=True
现在有一个内置的命令行选项可以做到:
There is now a built-in command line option to do it:
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace Notebook.ipynb
或到另一个名为NotebookNoOut.ipynb
的文件:
Or to another file called NotebookNoOut.ipynb
:
jupyter nbconvert --ClearOutputPreprocessor.enabled=True \
--to notebook --output=NotebookNoOut Notebook.ipynb
jupyter nbconvert --help
也记录了--clear-output
选项,但是由于某些原因它没有起作用.
jupyter nbconvert --help
also documents a --clear-output
option, but for some reason it did not work.
在Jupyter 4.4.0中测试,笔记本电脑== 5.7.6.
Tested in Jupyter 4.4.0, notebook==5.7.6.
这篇关于如何从Linux终端的所有单元中清除IPython Notebook的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!