There are some differences when running from py2exe
(encodings, sys.path ...)
Enable a way for a script (sys.py2exe, PY2EXE in
globals, ...) to know if it is running from py2exe or not.
Logged In: YES
I use this code snippet:
if not hasattr(sys, "frozen") and not hasattr(sys, "importers"):
....# we are running as frozen executable
It has the advantage that it works with the 'old' and the
'new' py2exe, and should also work with cx_freeze, McMillan,
and the freeze tool.
The newer py2exe versions set sys.frozen to something like
'console_exe', 'windows_exe', and 'dll'.