Can I stop execution of current module in ipython

2019-02-16 10:19发布

问题:

I'd like to break out of the currently running program and be dropped back to the shell (without having to restart ipython)

回答1:

I had the same issue after reinstalling console2 and ipython on Windows. If you use the ipython.exe launcher, this seems to be a problem and it just closes the whole window. However, if you instead launch ipython with

python C:\python27\scripts\ipython-script.py

then it catches and handles the KeyboardInterrupt just fine and leaves me at the ipython prompt. Hooray.



回答2:

Control-C works in the normal interactive Python shell, it should work in ipy also (except the program is catching the keyboardInterrupt exception)



回答3:

Kind of a jenky method but I can often quit a process without exiting ipython by typing something like: ']='. It creates a syntax error, terminating the process and, thereby, returning you to the ipython shell.



回答4:

For the current version of IPython(Jupyter), you can simply click on Interrupt option under kernel tab.



标签: ipython