Question on running exe file in Python

Chris Rebert clp2 at rebertia.com
Sun Feb 13 08:58:50 EST 2011


On Sun, Feb 13, 2011 at 4:56 AM, joy99 <subhakolkata1234 at gmail.com> wrote:
> Dear Room,

Just a friendly FYI: that's a strange salutation; comp.lang.python AKA
python-list isn't a chat room, at least in the normal sense of the
term.

> I am using Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.
> 1500 32 bit (Intel)] on win32 on Windows XP (SP2).
>
> Trying to create an .exe file of my scripting file I had saved it
> as .exe instead of .py file. It seems created. But how to run it? I
> tried command prompt, seems unresponsive.

You can't compile things to executables (i.e. machine code, i.e. .exe
files) just by changing the file extension; you have to use a compiler
to generate the .exe. Additionally, Python is normally an interpreted
language; hence, it does not normally produce independent executables
(unless possibly you're using a non-CPython implementation of Python).
You can however generate self-contained executables for Python
programs using special tools such as py2exe, cx_freeze, etc., which
judging by your other post, you're already aware of. So, if you want
to generate a .exe, you'll need to get one of those tools working.

(Renaming a text .py file to a .exe results in your CPU trying to
treat the text like it's binary machine code; since it's not machine
code, the CPU ends up executing gibberish instructions, resulting in
an error, freeze, or similar that causes the unresponsiveness you're
observing.)

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list