restart kernel python
import IPython IPython.Application.instance().kernel.do_shutdown(True) #automatically restarts kernel
import IPython IPython.Application.instance().kernel.do_shutdown(True) #automatically restarts kernel