Creating Python "executables" on Windows?

Alex Martelli alex at magenta.com
Tue Aug 8 11:47:20 EDT 2000


"Hrvoje Niksic" <hniksic at iskon.hr> wrote in message
news:wkr97zhkkc.fsf at iskon.hr...
> "Daniel Dittmar" <daniel.dittmar at sap.com> writes:
>
> > - if you're using the DOS prompt, you can set the environment variable
> > PATHEXT to include .py.
>
> How do I do that?  When I try `echo %PATHEXT%', I only get "ECHO is on".

Are you on NT?  PATHEXT works there only.  Using CMD.EXE?

But that's just to be able to say 'foo' rather than 'foo.py', anyway.

> Something like `SET PATHEXT=.py' doesn't seem to do the trick either.
>
> > If Python is properly installed (the command 'assoc .py' prints
> > '.py=Python.File'),
>
> `assoc .py' prints "Bad command or file name".

It's a builtin command I think (again for NT and CMD.EXE)...?  Are
you on NT?  What level/SP...?

> > python scripts can now be placed in your path and will be found.
>
> That would be very cool.  I've installed Python using the installer
> provided on www.python.org (py152.exe).  I'm not sure how I missed the
> assoc thing.

It should do it automatically.  From Explorer, have a look at
View/Folder Options.../File Types; is Python File among the
registered filetypes...?


> > From the docs: To use PythonLauncher to start a script named
> > 'foo.py', make a copy of PythonLauncher named 'foo.exe' and place it
> > somewhere in the path.
>
> That seems similar to the .BAT solution -- two files per script.

Yes, the .exe and the .py (and the .pyc it will generate too).  The
advantage is finessing a Windows bug with I/O redirection.


Alex






More information about the Python-list mailing list