Question on running exe file in Python

Discussion in 'Python' started by joy99, Feb 13, 2011.

  1. joy99

    joy99 Guest

    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.
     
    joy99, Feb 13, 2011
    #1
    1. Advertising

  2. joy99

    Chris Rebert Guest

    On Sun, Feb 13, 2011 at 4:56 AM, joy99 <> 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
     
    Chris Rebert, Feb 13, 2011
    #2
    1. Advertising

  3. joy99

    joy99 Guest

    Thanks for your reply.
    On Feb 13, 6:58 pm, Chris Rebert <> wrote:
    > On Sun, Feb 13, 2011 at 4:56 AM, joy99 <> 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 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.
     
    joy99, Feb 13, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page