RE: Hiding console with program compiled in PY2EXE

Discussion in 'Python' started by Pieter Claerhout, Dec 19, 2003.

  1. Specify the -windows option in the py2exe command line. Example:

    python setup.py py2exe --windows

    By default, if the script ends with .pyw, it will create a console-less GUI
    app. If it ends with .py, it will create a console application. By using the
    --console or --windows flags, you can control this behaviour.

    What I normally do to freeze a program this way is the following:

    1. I create an executable using the --console option.

    2. Run it on a computer that doesn't have Python installed to make sure
    every required part is present. If not, adjust and go back to step 1.

    3. After the program is working fine, I run py2exe using the --windows
    option to create the console-less GUI app.

    4. Test it again.

    It might be handy to wrap the main function of your application in a
    try/except statement and redirect the traceback to a file so that you know
    what went wrong if you run the application without the console window.

    Cheers,


    pieter


    -----Original Message-----
    From: [mailto:]
    Sent: 19 December 2003 07:34
    To:
    Subject: Hiding console with program compiled in PY2EXE


    Hi all,

    I know that to hide a console normally you simply change the extension
    from .py to .pyw. That's simple enough. However I can't seem to
    accomplish the same thing after freezing the program. I've tried
    building the setup file with the python script as a .pyw file, but it
    crashes and doesn't give me a reason. This is of course because the
    debug window doesn't open, so you don't know what happened (ahh, the
    irony).

    Does anyone know how to successfully freeze a program with py2exe?

    Many thanks,
    Marc
    --
    http://mail.python.org/mailman/listinfo/python-list
     
    Pieter Claerhout, Dec 19, 2003
    #1
    1. Advertising

  2. Pieter Claerhout

    Marc Guest

    Thanks to all the replies. I tried it using the --windows option, but
    I get the same problem. However I'm also increasing the difficulty a
    little bit by using COM with py2exe.

    Here's my setup file:

    # setup.py
    from distutils.core import setup
    import py2exe

    setup(name="CCT",
    scripts=["CCT.py"],
    )


    Here's the command I use to initiate the process:

    python setup.py py2exe --progid "Excel.Application" --windows

    It appears to compile successfully, but I get the same problem as I
    did when inserted my program with the .pyw option. It starts to open,
    then dies.

    Does adding other options, such as COM, interfere with this process?
    Does COM need the window for some reason?

    Thanks,
    Marc
     
    Marc, Dec 19, 2003
    #2
    1. Advertising

  3. Pieter Claerhout

    Marc Guest

    Update!

    Silly me. I had a problem further upstream that was causing it to
    fail. It has nothing to do with the COM interaction. Works perfect
    now!

    Thanks again,
    Marc
     
    Marc, Dec 20, 2003
    #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.
Similar Threads
  1. Marc
    Replies:
    3
    Views:
    675
    Anand Pillai
    Dec 19, 2003
  2. Miktor
    Replies:
    7
    Views:
    12,197
    Joe Bacigalupa
    Aug 9, 2005
  3. David Lyon
    Replies:
    0
    Views:
    260
    David Lyon
    Apr 15, 2009
  4. David Lyon
    Replies:
    0
    Views:
    210
    David Lyon
    Apr 15, 2009
  5. p_tierchen
    Replies:
    1
    Views:
    318
Loading...

Share This Page