如何解决如何在 Try Catch 中停止下一个单元格执行 (Colab / autosklearn)
我尝试/捕获了 google colab 上 autosklearn 的导入错误,我需要做白痴证明,我的意思是,非常清楚地给出每个细节,并控制所有期望等等。由于一旦安装了运行时需要重新启动,我需要给出消息,所以这里是我的代码:
#from exceptions import TypeError
try:
import autosklearn
print('autosklearn: %s' % autosklearn.__version__)
except ImportError as e:
print("ERROR:",e)
print(' Installling autosklearn ')
!sudo apt-get install build-essential swig
!curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install
!pip install auto-sklearn
print(' Now you should restart Runtime ( menu -> Restart Runtime) ')
assert False
except Exception as e:
print("Exception:",e)
print(' Probably ... you should restart Runtime ( menu -> Restart Runtime) ')
assert False
raise SystemExit("Stop right there!")
我同时尝试断言 False 和引发系统退出,但一个给我 AssertionError,另一个只是停止那个单元格执行并继续下一个
解决方法:确保我可以创建一个函数,它带有 if 进入无效指令 [print(undefinedVar)] 并在每个单元格中调用此函数,但对我来说似乎很脏
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。