Trouble with subprocess.call(...) and zsh script (OSError: [Errno 8] Exec format error)
Michael George Lerner
mglerner at gmail.com
Sun Nov 11 10:54:59 EST 2007
Hi,
(Python 2.5, OS X 10.4.10)
I have a program called pdb2pqr on my system. It is installed so that
"pdb2pqr" is in my path and looks like:
#\!/bin/zsh -f
/sw/share/pdb2pqr/pdb2pqr.py "$@"
When I call it via this script:
#!/usr/bin/env python
import subprocess
import tempfile
args = ('/sw/bin/pdb2pqr','--help')
output_file = tempfile.TemporaryFile(mode="w+")
print "Running",args
retcode =
subprocess.call(args,stdout=output_file.fileno(),stderr=subprocess.STDOUT)
output_file.close()
I get this error:
localhost~/tmp$ ./x.py
Running ('/sw/bin/pdb2pqr', '--help')
Traceback (most recent call last):
File "./x.py", line 9, in <module>
retcode =
subprocess.call(args,stdout=output_file.fileno(),stderr=subprocess.STDOUT)
File "/sw/lib/python2.5/subprocess.py", line 443, in call
return Popen(*popenargs, **kwargs).wait()
File "/sw/lib/python2.5/subprocess.py", line 593, in __init__
errread, errwrite)
File "/sw/lib/python2.5/subprocess.py", line 1051, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
But when I change it to directly call the script that the zsh script
calls like this:
args = ('/sw/share/pdb2pqr/pdb2pqr.py','--help')
everything works:
localhost~/tmp$ ./x.py
Running ('/sw/share/pdb2pqr/pdb2pqr.py', '--help')
This is with 2.5 on OS X 10.4.10. I'm happy to provide whatever
additional information might be useful.
Thanks,
-michael
More information about the Python-list
mailing list