py2exe question

Thomas Heller theller at python.net
Sat Nov 1 15:10:30 EST 2003


"Jimmy Retzlaff" <jimmy at retzlaff.com> writes:

> As mentioned earlier (was it another thread?), temporarily letting
> py2exe display a console can aid in debugging py2exe specific problems
> by letting you see unhandled exceptions and other output. Once things
> are working then turn the console off again.

Right, that's also the approach I normally use.

The 0.5 py2exe helps with this, it creates very small executables, all
the Python modules are in a shared zip-archive.  You can easily create a
concole plus a console-less version of an exe from the same setup
script, use the console version to see the tracebacks when the app
doesn't start, and, if everything works, distribute the console-less
exe.

> I do have vague memories of hearing about people having problems with
> some buffers filling up if there is no console and there is a
> significant amount of console output.

It's my experience that you get IOErrors after some 'print ...'
statements when there is no console.
But, since there *may* be problems in a gui app, you need some kind of
error-logging anyway - be it a window displaying tracebacks, writing
them to a file, or whatever.

To see what the program is doing, print statements are a useful feature.
To have them easily turned off, I normally write

    if __debug__:
        print "something"

So, when you are runnig the program with 'python myapp.py', I can see
this stuff on the console.  When building the exe, I'll build with
optimize on, and the stuff in the if __debug__ block is 'optimized'
away.

Thomas




More information about the Python-list mailing list