making a python program in windows

rustom rustompmody at
Thu May 21 13:01:20 CEST 2009

On May 21, 3:19 pm, "Martin P. Hellwig" <martin.hell... at>
> Rustom Mody wrote:
> > I know how to make a python script behave like a (standalone) program
> > in unix --
> > 1. put a #! path/to/python as the first line
> > 2. make the file executable
> > The closest I know how to do this in windows is:
> > r-click the file in win-explorer
> > goto properties
> > goto open with
> > change pythonw to python
> > Can someone enlighten me about a more scriptish way of doing this?
> > Basically if I have to setup that program on other (windows) m/cs is
> > there some .bat or .vbs or some regedit thingy Ive to do to avoid the
> > Rt-click routine?
> Since you don't know for sure if a Python environment is available on
> the other windows machine and whether the file associations are
> configured correctly, the best thing you can do is to use something like
> py2exe and distribute the result of that.

Oh - Oh! Not an exe please! I dont want to move away from readable
text files if possible.

I certainly know that python2.6 is installed.
Why that installation by default does not put python.exe on the path I
dont know but that is best corrected by hand.

Bottom Line: Assume that from a command line (cmd) python runs and
gives its interpreter prompt.
When run from cygwin it hangs but thats another story. Just dont
assume cygwin.

i suppose the question is entirely about setting properly (and
grokking) file associations -- why is a .py file associated with
pythonw and not python? And is making this association right enough to
make a .py file in windows behave like a shebang file in unix?

[And is there a more appropriate list for such questions?]


More information about the Python-list mailing list