[Tutor] Re: how to make .py file to .exe file?

Abel Daniel abli at freemail.hu
Wed Dec 31 10:27:15 EST 2003


"陈任" writes:

> I'm a real beginner.I want to ask a question. How to make a executable file
>  so that
> I can click it and run it directly? Thanks.

I don't think you have to make it into an executable file for that. IIRC, under
Windows, the default install of python associates the .py and .pyw endings
with pythonw.exe, so clicking on a file whose name ends in .py runs it. The
problem might be that this opens a command-line window which is closed when
the program finishes, so you might not be able to inspect the results (and
only see the screen flash as the window is opened and the closed).

(see  http://www.python.org/doc/faq/windows.html#how-do-i-make-python-scripts-executable)

To make the command-line window stay open, you should make it wait for a
keypress when it is finished, with the getch( ) function of the msvcrt module
(for example)


-- 
Abel Daniel



More information about the Tutor mailing list