matplotlib-0.87.2 on Windows - using subprocess.Popen()

[I'm moving this discussion to matplotlib-devel.]

I just found the bug report that deals with the IDLE/pythonwin/subprocess
issue:
http://sourceforge.net/tracker/index.php?func=detail&aid=1124861&group_id=5470&atid=105470

The bug is not assigned to anyone, but a workaround is listed: stdin, stdout,
and stderr all have to be specified. I tested this on windows with IDLE and
pythonwin, and it does appear to fix the problem:

from subprocess import Popen, PIPE, STDOUT
p = Popen('dir', shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
stat = p.wait()
print p.stdout.read()

As soon as I know that matplotlib builds subprocess correctly for windows
computers with <python-2.4, I will unmask the subprocess code again in svn.
Any ideas when we might have an answer to this question?

Let me remind why it is important to use subprocess with an example. If I try
to print some text but my latex syntax is incorrect, mpl needs to catch latex
exit status and raise an error. subprocess is needed to do this in a platform
independent way.

Darren

···

On Monday 20 March 2006 10:32, Randewijk P-J <pjrandew@...337...> wrote:

Darren,

I tried "idle -n" and got the same result:

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32 Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface. This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.1.2 ==== No Subprocess ====

>>> import subprocess
>>> process = subprocess.Popen(['dir'], shell=True,
>>> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    process = subprocess.Popen(['dir'], shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "C:\Python\lib\subprocess.py", line 533, in __init__
    (p2cread, p2cwrite,
  File "C:\Python\lib\subprocess.py", line 593, in _get_handles
    p2cread = self._make_inheritable(p2cread)
  File "C:\Python\lib\subprocess.py", line 634, in _make_inheritable
    DUPLICATE_SAME_ACCESS)
TypeError: an integer is required

PJR

> -----Original Message-----
> From: matplotlib-users-admin@lists.sourceforge.net
> [mailto:matplotlib-users-admin@lists.sourceforge.net] On
> Behalf Of Darren Dale
> Sent: 20 March 2006 16:19
> To: matplotlib-users@lists.sourceforge.net
> Subject: Re: [Matplotlib-users] matplotlib-0.87.2 on Windows
> - using subprocess.Popen()
>
>
> On Monday 20 March 2006 09:03, Randewijk P-J > > > > <pjrandew@…337…> wrote:
> > Darren,
> >
> > I prefer using PythonWin to IDLE. Any ideas how to solve the
> > subprocess.Popen() problem using PythonWin? What about using
> > "win32pipe"?
>
> I don't know how to solve it for pythonwin, maybe you could
> investigate it
> with a google search (thats how I learned about the problem
> and the solution
> for idle).
>
> I suppose win32pipe is part of pywin32. If that is the case,
> I dont think I
> can support using it; we are trying to eliminate
> dependencies, not add to
> them. Subprocess is acceptable because it is part of the
> python-2.4 standard
> library and we were able to add it to the mpl tree for older
> versions of
> python.
>
> Darren
>
> > -----Original Message-----
> > From: Darren Dale [mailto:dd55@…143…]
> > Sent: 20 March 2006 15:52
> > To: Randewijk P-J <pjrandew@…337…>
> > Subject: Re: ASPN : Python Cookbook : Module to allow Asynchronous
> > subprocess use on Windows and Posix platforms
> >
> >
> > I forgot to mention, you may be able to avoid these errors
>
> by starting
>
> > idle with the -n flag.
> >
> > On Monday 20 March 2006 08:36, you wrote:
> > > Aha!
> > >
> > > In both the IDLE & PythonWin (my default my using pylab)
>
> shells it
>
> > > fails… but not from the python shell…
> > >
> > > PJR
> > >
> > > > -----Original Message-----
> > > > From: Darren Dale [mailto:dd55@…143…]
> > > > Sent: 20 March 2006 15:25
> > > > To: Randewijk P-J <pjrandew@…337…>
> > > > Subject: Re: ASPN : Python Cookbook : Module to allow
>
> Asynchronous
>
> > > > subprocess use on Windows and Posix platforms
> > > >
> > > >
> > > > Also, are you running this from IDLE? If so, please try
>
> running it
>
> > > > from a regular python shell, or better, run a script
>
> from the dos
>
> > > > shell.
> > > >
> > > > On Monday 20 March 2006 08:06, you wrote:
> > > > > This is what I get:
> > > > > >>> import subprocess
> > > > > >>> process = subprocess.Popen(['dir'], shell=True,
> > > > >
> > > > > stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
> > > > > Traceback (most recent call last):
> > > > > File "<interactive input>", line 1, in ?
> > > > > File "C:\Python\lib\subprocess.py", line 533, in __init__
> > > > > (p2cread, p2cwrite,
> > > > > File "C:\Python\lib\subprocess.py", line 593, in
>
> _get_handles
>
> > > > > p2cread = self._make_inheritable(p2cread)
> > > > > File "C:\Python\lib\subprocess.py", line 634, in
> >
> > _make_inheritable
> >
> > > > > DUPLICATE_SAME_ACCESS)
> > > > > TypeError: an integer is required
> > > > >
> > > > > PJR
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Darren Dale [mailto:dd55@…143…]
> > > > > > Sent: 20 March 2006 14:49
> > > > > > To: Randewijk P-J <pjrandew@…337…>
> > > > > > Subject: Re: ASPN : Python Cookbook : Module to allow
> > > >
> > > > Asynchronous
> > > >
> > > > > > subprocess use on Windows and Posix platforms
> > > > > >
> > > > > >
> > > > > > Hi P-J,
> > > > > >
> > > > > > On Monday 20 March 2006 7:39 am, you wrote:
> > > > > > > Dear Darren,
> > > > > > >
> > > > > > > Maybe this could help solve the Windows problem with
> > > > > >
> > > > > > Popen()… don't
> > > > > >
> > > > > > > know about the 2.3 issue however…
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/4405
>
> > > > > > > 54
> > > > > >
> > > > > > I'm not convinced that there is an issue with
>
> subprocess.Popen
>
> > > > > > in windows. I tested the following block on windows (with
> > > >
> > > > python-2.4)
> > > >
> > > > > > and it worked fine.
> > > > > >
> > > > > > import subprocess
> > > > > > process = subprocess.Popen(['dir'], shell=True,
> > > > > > stdout=subprocess.PIPE,
> > > > > > stderr=subprocess.STDOUT)
> > > > > > stat = process.wait()
> > > > > > print process.stdout.read()
> > > > > >
> > > > > > I posted this to the list last week. Did you test it?
> > > >
> > > > –
> > > > Darren S. Dale, Ph.D.
> > > > Cornell High Energy Synchrotron Source
> > > > Cornell University
> > > > 200L Wilson Lab
> > > > Rt. 366 & Pine Tree Road
> > > > Ithaca, NY 14853
> > > >
> > > > dd55@…143…
> > > > office: (607) 255-9894
> > > > fax: (607) 255-9001
>
> –
> Darren S. Dale, Ph.D.
> Cornell High Energy Synchrotron Source
> Cornell University
> 200L Wilson Lab
> Rt. 366 & Pine Tree Road
> Ithaca, NY 14853
>
> dd55@…143…
> office: (607) 255-9894
> fax: (607) 255-9001
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking
> scripting language that extends applications into web and
> mobile media. Attend the live webcast and join the prime
> developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&

dat=121642
_______________________________________________
Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live
webcast and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Darren S. Dale, Ph.D.
Cornell High Energy Synchrotron Source
Cornell University
200L Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

dd55@...143...
office: (607) 255-9894
fax: (607) 255-9001

Darren Dale wrote:

As soon as I know that matplotlib builds subprocess correctly for windows computers with <python-2.4, I will unmask the subprocess code again in svn. Any ideas when we might have an answer to this question?

I suspect that there are relatively few Python 2.3 users on Windows anymore, so I say unmask it now. (It's not like the case in linux where big distros, e.g. Debian, are still on Python 2.3. Windows doesn't have "distros", and the Python 2.4 installer has been around a longish time now, Microsoft offers a free compiler compatible with the Python 2.4 release from python.org which is not the case for Python 2.3. Finally, all the major packages I use are available, sometimes exclusively, in Windows binary packages for Python 2.4. I think these things indicate that Python 2.4 on Windows is now the dominant version.)

Also, any potential compilation error is going to bite them as soon as they try installing, so we should hear about it pretty quickly and be able to adjust setupext.py or whatever needs to be fixed.

Cheers!
Andrew