IPython Notebook在打开时运行所有单元格 [英] IPython Notebook run all cells on open

查看:954
本文介绍了IPython Notebook在打开时运行所有单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个IPython noteboook,我试图以某种方式设置它,以便在打开笔记本时自动运行所有单元格。

I have an IPython noteboook and I'm trying to set it up in a way so that all cells are ran automatically when the notebook is opened.

此行为与包含小部件的笔记本的保存输出不同。当运行包含它们的单元格时,小部件似乎只为我呈现。请考虑以下示例:

This behaviour is different from saved output for notebooks which contain widgets. Widgets only seem to get rendered for me when the cells containing them are run. Consider the following example:

from IPython.display import display
from IPython.html.widgets import IntSlider

w = IntSlider()
display(w)

滑块不是显示直到单元格被执行。

The slider is not displayed until the cell is executed.

这可以通过笔记本元数据或配置文件来实现吗?

Is this something that can be accomplished through Notebook Metadata or configuration files?

编辑: https://try.jupyter.org/ 似乎正在做类似这样的事情:请注意,打开页面时笔记本没有运行,打开时显示输出。

https://try.jupyter.org/ seems to be doing something like this: Notice that the notebooks are not running when you open the page and display output when they are opened.

EDIT2:添加示例。

推荐答案

我刚刚找到了一种方便的方法。如果安装nbextensions包( https://github.com/ipython-contrib/jupyter_contrib_nbextensions ) ,其中一个扩展称为初始化单元,允许您标记某些单元格在加载笔记本时自动运行。

I just found a way to do this quite easily. If you install the nbextensions package (https://github.com/ipython-contrib/jupyter_contrib_nbextensions), one of the extensions is called "Initialization cells" and allows you to mark certain cells to run automatically when the notebook is loaded.

这篇关于IPython Notebook在打开时运行所有单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆