I'd like to break out of the currently running program and be dropped back to the shell (without having to restart ipython)
5 Answers
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.

- 1,071
- 1
- 14
- 19
-
2Totally works, you could add `--confirm-exit` to the command on top of that. – Kos Nov 23 '12 at 16:53
Control-C works in the normal interactive Python shell, it should work in ipy also (except the program is catching the keyboardInterrupt exception)

- 21,853
- 1
- 25
- 29
-
I'm on a Mac atm and it works. Could be a setting or a Windows thing. Does it behave the same with a clean configuration file ? – sleeplessnerd Aug 28 '11 at 00:19
-
This is the case because there is a separate launcher provided titled ipython.exe in Windows. Since that just opens up a python shell, the exit criteria for it is to close the process i.e. the shell (and so in this case it closes the window) – synaptikon Oct 13 '14 at 22:22
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.

- 1,559
- 1
- 16
- 22
-
This will do nothing for the code that is already running, ie. if you start a long running loop and while its being executed you type rubbish characters, the loop will be uninterrupted and the synthax error will be thrown after the loop completes. – mac13k Jun 16 '16 at 04:22
This answer may be a little too late, but for anyone who comes looking for an answer, you can use ESC

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

- 75
- 1
- 5
-
3The question is not about Ipython Notebook (now Jupyter), but just IPython (interactive shell) – jorgeh Jan 09 '17 at 19:16