15

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

DanB
  • 3,755
  • 4
  • 22
  • 22

5 Answers5

11

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.

partofthething
  • 1,071
  • 1
  • 14
  • 19
4

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

sleeplessnerd
  • 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
0

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.

ansonw
  • 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
0

This answer may be a little too late, but for anyone who comes looking for an answer, you can use ESC

Mussie
  • 41
  • 4
-1

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

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