简体   繁体   English

在主要笔记本之前执行jupyter笔记本中的特定单元格

[英]Execute specific cells in jupyter notebook before main one

Say I have a main cell in my notebook, lets call in main . 假设我的笔记本中有一个主电池,我们可以在main电话中拨打电话。 I don't want to run a whole bunch of cells each time I use main, but I have to because main depends on the functions in them. 我不想每次使用main时运行一大堆单元格,但我必须因为main取决于它们中的函数。

Hence, if main depends on say cells c1 and c2 is there a special magic command or something one can place in c1 and c2 , that tells the notebook to run these before I run main . 因此,如果main依赖于说单元格c1c2是否有一个特殊的魔术命令或者可以放在c1c2 ,它会告诉笔记本在运行main之前运行这些命令。 My notebooks typically contain hundreds of cells, so loading them all from the start is not really an option. 我的笔记本通常包含数百个单元格,因此从一开始就加载它们并不是一个选择。

Thanks 谢谢

PS. PS。 I am fully aware that I can take all of this out of notebooks and just import the whole lot. 我完全清楚,我可以从笔记本电脑中取出所有这些,然后输入整个批次。 I specifically do not want to do that. 我特别不想那样做。

I don't think you can do this without extensions. 如果没有扩展,我认为你不能做到这一点。

Have a look on init_cell extension. 看看init_cell扩展。 It allows you to mark some cells and run them on load\\demand. 它允许您标记一些单元格并在load \\ demand上运行它们。

Here is the installation instructions . 这是安装说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM