即使在Jupyter的当前单元格中发生错误,如何自动执行下一个单元格? [英] How to automatically execute next cell even if an error occurs in the current cell in Jupyter?
问题描述
我正在Jupyter笔记本电脑中运行一个单元,一段时间后(通常是几个小时)肯定会发生错误.但是,即使在发生此错误之后,我也希望编译器继续前进到下一个单元格,并运行我放入队列中的其余单元格,以便在此单元格完成后再运行.
I am running a cell in Jupyter notebook where an error is bound to occur after some time(usually hours). But even after this error occurs, I want the compiler to just move on to the next cell and run the remaining cells that I put in the queue to be run after this cell finishes.
我知道例外也许可以做到这一点,但是我想知道是否有其他特定于Python或Jupyter笔记本的方法可以解决这个问题.
I know exceptions might be able to do this, but I wanted to know if there was any other way specific to Python or Jupyter notebook that might do the trick.
单元1:一些代码正在运行 #这里会发生错误并停止执行
Cell 1: Some code running # Error will occur here and stop the execution
单元格2,3 ...,n:一些代码 #单元格1中发生错误后,代码仍应运行
Cell 2,3...,n: Some code # Code should still run after the error occurs in Cell 1
感谢您提出任何解决方案.感谢您的帮助.
Thanks for any solutions. The help is appreciated.
推荐答案
Jupyter Notebook nbextensions扩展名为Runtools,它允许您运行所有单元格并使用快捷键Alt + F忽略错误.请参见
There's a Jupyter Notebook nbextensions extension called Runtools which allows you to run all cells and ignore errors with the shortcut Alt + F. See Installing jupyter_contrib_nbextensions on how to install nbextensions and enable extensions like Runtools.
这篇关于即使在Jupyter的当前单元格中发生错误,如何自动执行下一个单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!