Win32: Running python programs from a Cygwin shell

Jorgen Grahn jgrahn-nntq at algonet.se
Sat Feb 14 05:52:06 EST 2004


I couldn't think of a good solution, and it's hard to Google for...

I write python command-line programs under Win2k, and I use the bash shell
from Cygwin.  I cannot use Cygwin's python package because of a binary
module which has to be compiled with Visual C 6.

My scripts start with a '#!/usr/bin/env python' shebang, as God intended.

Now, I assume I can make cmd.exe run foo.py by asociating *.py with the
python interpreter.

However, if foo.py is in my path and I try to run it from bash, what happens
is:

- bash runs env /cygdrive/h/bin/foo.py
- env runs something like 'python /cygdrive/h/bin/foo.py'
- ... and python (which doesn't know about Cygwin-style paths)
  croaks on this, of course

Is there a way around this, which doesn't make my script unusable if I moved
it to a Unix box, or ran it from cmd.exe?  

I'd prefer not to write wrapper scripts in perl/bash/BAT...

/Jorgen

-- 
  // Jorgen Grahn <jgrahn@      ''If All Men Were Brothers,
\X/                algonet.se>    Would You Let One Marry Your Sister?''



More information about the Python-list mailing list