[Edu-sig] IDLE and Matplotlib
Hans Fangohr
H.FANGOHR at soton.ac.uk
Wed Jan 12 17:00:11 CET 2005
Hi John,
> I know you are already in communication/waiting for a bugfix on this, but I
> have a quick inquiry. This sounds related to issues I've had with my graphics
> library (now solved, knock on wood). I would think that running IDLE -n would
> solve this problem for you. Please see my question below:
>
> Hans Fangohr wrote:
>
>> Dear all,
>>
>> I am about to teach Python to a number of students who already know how
>> to use Matlab (on a basic level). For that reason, the matplotlib library
>> for plotting curves is ideally suited (it seems quite good anyway).
>>
>> The teaching computers are Win XP machines. I have settled for the
>> Enthough Python Edition and the latest matplotlib (both executables can
>> be found in www.soton.ac.uk/~fangohr/download/python).
>>
>> I have prepared the exercises on linux and am now trying to run them in
>> windows. This is where I realised that matplotlib doesn't work well with
>> IDLE.
>>
>> More particularly, it is known that the default backend TkAgg doesn't
>> work with IDLE (see here
>> http://matplotlib.sourceforge.net/backends.html#TkAgg)
>> but it appears to work with "IDLE -n" (this is what it says on that web
>> page).
>>
>> The problem I experience is this:
>>
>> -start idle
>> -execute these commands:
>>
>> import pylab
>> pylab.plot(range(10))
>> pylab.show()
>>
>> This produces a figure window which seems to work fine.
>>
>> At this point when closing the figure window, I can't get the IDLE prompt
>> active again. (It seems that IDLE thinks the program and the figure
>> process are still running, and is waiting for control to return.)
>>
>> This, in itself, is maybe not suprising. However, the idle -n switch
>> doesn't seem to solve the problem for me (see below).
>>
>> The same problem is observed when I execute a program in the IDLE editor
>> (by pressing F5).
>>
>> What do people think how I should continue?
>>
>> I could
>>
>> - try to make IDLE work with matplotlib (I think this is my preferred
>> option)
>> In that case, how do I tell IDLE on Windows to start with -n? (Not a
>> Windows freak). In the start menu, I can change the properties for the
>> link to idle from '''
>>
>> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw"
>>
>> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw" "-n"
>>
>> but this doesn't seem to solve the problem: I get exactly the same
>> behaviour as described above.
>
> When you say you get exactly the same result, does this mean that IDLE's
> behavior is unchanged?
Sorry I was inprecise. In fact, yesterday I didn't know what to look for
(it is the 'no subproccess message'). What I meant with 'exactly the same
result' was that IDLE hangs after I closed the figure window.
I can now confirm that the syntax I used above, i.e.
C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw" "-n"
is correct to start Python with no subprocesses.
> If so, you are not getting the -n flag set. IDLE
> should fire up with a message that simply says "no subprocess" instead of the
> warning about personal firewalls. If you just mean that Matplotlib acts the
> same, that's a different story. What happens if you change the menu item to
> this:
>
> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw -n"
This, by the way, results in a 'program not found error' presumably
because pythonw is looking for a program of name
"C:\Python23\Lib\idlelib\idle.pyw -n".
> Unfortunately, I don't have access to Windows to try this out at the moment.
> Another way to fire up IDLE in the -n mode is to right-click on a Python file
> and then select "edit with IDLE." I actually find it annoying that opening
> IDLE this way puts it in -n mode, but it might be a way to test out exactly
> what's happening.
That's useful information for me, thanks.
To complete the story: the matplotlib people (John Hunter and Todd Miller)
have been very helpful. They suggested to uncomment this line
#os.environ['PYTHONINSPECT'] = '1'
in the show method of site-packages/matplotlib/backends/backend_tkagg.py,
and to use the interactive mode (i.e. set interactive=True in
share/matplotlib/.matplotlibrc). Having done that, all works well when
IDLE is started with the -n flag. (which -- as it happens seems to be
identical to rightclick on a Python file and select 'edit with idle'.)
Hope this is useful,
Hans
>
>
>
>>
>> _______________________________________________
>> Edu-sig mailing list
>> Edu-sig at python.org
>> http://mail.python.org/mailman/listinfo/edu-sig
>>
>>
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>
-------------------------------------------------
Dr Hans Fangohr
Computational Engineering & Design Research Group
School of Engineering Sciences
University of Southampton
Southampton, SO17 1BJ
United Kingdom
Location: Building 25, Room 1027
phone : +44 (0) 23 8059 8345
fax : +44 (0) 23 8059 7082
email : fangohr at soton.ac.uk
-------------------------------------------------
More information about the Edu-sig
mailing list