Trouble with and zsh script (OSError: [Errno 8] Exec format error)

Michael George Lerner mglerner at
Sun Nov 11 16:54:59 CET 2007


(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/ "$@"

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 =,stdout=output_file.fileno(),stderr=subprocess.STDOUT)

I get this error:

localhost~/tmp$ ./
Running ('/sw/bin/pdb2pqr', '--help')
Traceback (most recent call last):
  File "./", line 9, in <module>
    retcode =,stdout=output_file.fileno(),stderr=subprocess.STDOUT)
  File "/sw/lib/python2.5/", line 443, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/sw/lib/python2.5/", line 593, in __init__
    errread, errwrite)
  File "/sw/lib/python2.5/", 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/','--help')

everything works:

localhost~/tmp$ ./
Running ('/sw/share/pdb2pqr/', '--help')

This is with 2.5 on OS X 10.4.10. I'm happy to provide whatever
additional information might be useful.



More information about the Python-list mailing list