Question on running exe file in Python

J

joy99

Dear Room,

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.

Best Regards,
Subhabrata.
 
C

Chris Rebert

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
 
J

joy99

Thanks for your reply.
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 know that. It is a highly technical room. I have been visiting this
room for last 4 yrs or so, greeted people in the same way, but someone
felt hurt I saw for the first time!
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
All you have to get a solution. That's the goal. Not how approach
should be.
You may be more learned, but doing an .exe file works. I googled out
and found the answer.
But somehow, I am finding the people visiting this forum have either
downsized, or their quality degraded.
I often find a web search gives better answers.
You can save as .pyw for .dll files. For .exe files, saving as .exe
simply works, you can get the result by
importing os, or by simply executing it from command prompt.

Best Regards,
Subhabrata.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top