Is it possible to restart an ipython
Kernel NOT by selecting Kernel
> Restart
from the notebook GUI, but from executing a command in a notebook cell?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As Thomas K. suggested, here is the way to restart the ipython
kernel from your keyboard:
import os
os._exit(00)
回答2:
To define a function that restarts the Jupyter kernel, I've successfully used:
from IPython.display import display_html
def restartkernel() :
display_html("<script>Jupyter.notebook.kernel.restart()</script>",raw=True)
then calling
restartkernel()
when time for the restart.