ipython notebook,IPython Notebook在打开时运行所有单元格

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?

EDIT: 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: Adding example.

解决方案

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值