Creating Python "executables" on Windows?
Alan Gauld
alan.gauld at gssec.bt.co.uk
Tue Aug 8 11:27:17 EDT 2000
> I have one problem, though: on Unix systems, it's very easy to create
> a script that you can run as an executable by placing "#!/usr/bin/python"
> (or the /usr/bin/env variant). I wonder how to do the same on Windows?
It happens automatically in the Python setup.
Look at the .py iles in exolorer and they should have
little snake icons. If so just double click on them
to launch the program. The default runs it in a DOS box
but you can change the bindinfg to use pythonw instead
of python and it runs without the DOS box.
Of course you'll need to stop the DOS box from exiting
if you expect to see the results/output
raw_input("Type enter to exit...")
does that for you.
> It's certainly quite annoying to have to type "python executabl args"
If you need to provide args then thats harder, you'd need
to get the args by prompts using input/raw_input but that can be
done with:
if __name__ ==="__main__":
if len(sys.argv) = 1: # no args
arg1 = raw_input("Enter the first arg ")
# etc
else:
arg1 = sys.argv[1]
# etc
HTH,
Alan G.
--
=================================================
This post represents the views of the author
and does not necessarily accurately represent
the views of BT.
More information about the Python-list
mailing list