problem executing python scripts in cygwin bash shell

John J. Lee phrxy at csv.warwick.ac.uk
Thu Apr 5 22:33:38 EDT 2001


On Thu, 5 Apr 2001, David Humphrey wrote:
[...]
> I can run bash scripts that are in the path but not python scripts.  Each
> script has the appropriate (I think) #! declaration on the first line.
> Here's a short record of my tests:
[...]
> $ cat /usr/local/bin/test1.py
> #!d:/Utils/python20/python.exe
> print "Hello, World (from the python script)"
[...]
> $ test1.py
> d:\Utils\python20\python.exe: can't open file '/usr/local/bin/test1.py'
[...]
> From this, I infer that cygwin bash understands the #! notation properly, so
> I must have a problem with paths or some other configuration parameter.
> Also, I've run these same tests with c:\ instead of /cygdrive/c and d:\
> instead of /cygdrive/d.
[...]

Yes, you're right, I think.  You seem to be using a Python not linked with
cygwin1.dll, so it knows nothing about cygwin paths like /foo/bar/baz.
Your Python wants to be given a path to load its script from that looks
like c:/foo/bar/baz -- a standard windows path.  Cygwin finds your script
in /usr/local/bin, and passes that to Python, which Python doesn't
understand.  I don't know why cygwin does this in when it finds the path
in PATH, but not when you run a script by doing

cd /usr/local/bin
./test1.py

but that's what appears to do.  It's less suprising that this works:

d:/path/to/cygwin/usr/local/bin/test1.py

or

python `cygpath -w //usr/local/bin/test1.py`

Your other option is to get a python built under cygwin.  There are
probably binaries around now.


John




More information about the Python-list mailing list