问题
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.
来源:https://stackoverflow.com/questions/37751120/restart-ipython-kernel-with-a-command-from-a-cell