Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython keyboard interrupt CTRL + C inconsistent

I'm getting inconsistent responses from the Keyboard interrupt Ctrl+C in interactive python (run in xterm) after plotting from matplotlib.

As expected, when executing Ctrl+C inside ipython2 I get the KeyboardInterrupt message.

However, once I plot anything using matplotlib (specifically matplotlib.pyplot) Ctrl+C will exit the interactive python session, as opposed to exiting the running script in the interactive python session (if there is one).

A primitive example.

import numpy as n
import matplotlib.pyplot as m
x = n.linspace(0,4*n.pi,500)
y = x**2*n.sin(x)

m.plot(x,y)
m.show()

Preferrable behavior would be for Ctrl+C to always only interrupt a running script (if any is running), instead of the interactive python session itself.

like image 905
Abstracted Avatar asked Aug 11 '14 10:08

Abstracted


1 Answers

I did have the same problem for a long time. Try to run ipython with qt:

ipython --matplotlib=qt
like image 199
JeanPijon Avatar answered Oct 22 '22 19:10

JeanPijon