EDIT
Unfortunately, at the moment this is not possible. I found out that it is a bug in Spyder. The developers are still figuring out how to approach this.
Goal
Visualize data while debugging code (and I want to use Spyder too!).
Attempt #1: Run foo.bar from IPython from Spyder
Create a file named foo.py with the following code:
from ipdb import set_trace as st import matplotlib.pyplot as plt def bar(): st()
While in IPython, type the following:
In [4]: import foo In [5]: foo.bar() --Return-- None > somewhere_over_the_rainbow\foo.py(5)bar() 3 4 def bar(): ----> 5 st() ipdb> plt.plot([1, 2], [3, 4]) [<matplotlib.lines.Line2D object at 0x05CA8E90>] ipdb> plt.show()
Plot remains in "frozen" state. If I exit debugger, plot updates. If I try to close the plot, IPython crashes. Obviously both undesirable, and neither lets me see the data while debugging.
Attempt #2: Run foo.bar from IPython from command line
- Use same foo.py as in Attempt #1:
Open IPython from commandline:
In [4]: import foo In [5]: foo.bar() --Return-- None > somewhere_over_the_rainbow\foo.py(5)bar() 3 4 def bar(): ----> 5 st() ipdb> plt.plot([1, 2], [3, 4]) [<matplotlib.lines.Line2D object at 0x03904070>] ipdb> plt.show()
Program shows plot as I expect. BUT I want to use Spyder.
Attempt #3: Run baz.bar from IPython from command line
Write baz.py:
from ipdb import set_trace as st import matplotlib.pyplot as plt st()
Open IPython from commandline:
In [4]: import baz --Return-- None > somewhere_over_the_rainbow\baz.py(4)<module>() 2 import matplotlib.pyplot as plt 3 ----> 4 st() ipdb> plt.
Then Spyder fully freezes.
Any suggestions?
Note #1: In my full code, I have many files and many functions, so mashing it all together in one script without functions is not viable.
Note #2: Using any matplotlib interactive command (e.g. ion(), interactive(True), etc.) had no effect.
Note #3: Spyder version 2.0.12, Python 2.6, matplotlib 1.0.1.