Reset Ipython Kernel

Restart ipython Kernel with a command from a cell

As Thomas K. suggested, here is the way to restart the ipython kernel from your keyboard:

import os
os._exit(00)

Reset an IPython kernel without restarting

I used the %reset IPython magic function instead of restarting the kernel. That removes all the variables but does not perform again the imports. That is suitable for my application.

See IPython docs: http://ipython.readthedocs.org/en/stable/interactive/magics.html?highlight=magic#magic-reset

Restarting kernel, ipython console in spyder

I found the issue, I had sys.exit() in my EndProgram() function as well as at the end of my code as seen here: sys.exit(app.exec_()). Once I took out the sys.exit() in my EndProgram function and changed sys.exit(app.exec_()) to sys.exit(), it is working perfect.

Original Code

if __name__ == '__main__':
# from LoadIceberg2 import LoadData2
app = Application(sys.argv)
gui = ProgramGUI()

qr = gui.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
gui.move(qr.topLeft())
# app.processEvents()
npics=8
gui.show()

# behaviour to trigger on exit
sys.exit(app.exec_())

New code

if __name__ == '__main__':
# from LoadIceberg2 import LoadData2
app = Application(sys.argv)
gui = ProgramGUI()

qr = gui.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
gui.move(qr.topLeft())
# app.processEvents()
npics=8
gui.show()

# behaviour to trigger on exit
sys.exit()


Related Topics



Leave a reply



Submit