On 04/22/2010 12:18 PM, VictorMiller wrote:
I tried using sage -python

It still bombs out, but slightly differently: it now does a

raise child_exception in the _execute_child method of subprocess, and
gets the error string

OSError: [Errno 2] No such file or directory



On Apr 22, 12:58 pm, Jason Grout<[email protected]>  wrote:
On 04/22/2010 11:38 AM, VictorMiller wrote:

I have some old Python programs that I've been using, and would like
to use them as part of SAGE.  One particular function I have uses the
standard python module subprocess to call an external program, and
then process the output from that.  This has worked fine in python for
a number of years (through various python version changes).  However,
when I try to use it from within SAGE, when subprocess is finished
with the process and it tries to close the process handle it gets an
error

OSError: [Errno 2] No such file or directory.

[Actually I'm not sure if it's even able to spawn the process at all]


My guess is that your process can't find your executable. Try doing this (which will check that subprocess works and also check that your executable is found:

import subprocess
p=subprocess.Popen("/bin/sh",stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
output=p.communicate('which ls\n')
print output[0], output[1]

Replace the "which ls" command with "which <YOUR PROGRAM>" to just double-check that the spawned shell can see your program.

The above works for me in Sage, so I think subprocess works just fine in Sage.

Thanks,

Jason

--
Jason Grout

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to