How remove Tcl/Tk fom py2exe distribution?

Michael Peuser mpeuser at
Sat Aug 16 14:12:15 CEST 2003

Thank you Thomas, for these excellent advice. "verbose" of course just
supports debugging and does not prevent py2exe from beeing quite autistic.
And it does a good job in that: Not only sys.path but sys.prefix as well as
sys.exec_prefix are faked to the local directory. This makes it a little bit
harder to supplement the path info.

Tcl also has the nasty habbit to look arround according to sys.prefix
settings and trying this and that....

Nevertheless I think I can do the next step. It could be of help, if py2exe
- could become configurable (i.e. optionally leave the os variables as they
- make them somewhere available

Michael P

"Thomas Heller" <theller at> schrieb im Newsbeitrag
news:7k5dzwo9.fsf at

> Ok. First you should make sure that Tkinter is not found and copied by
> py2exe. The '--exclude' flag could be used, or the above __import__
> trick.
> Then, you should make sure that your executable finds the 'standard'
> Tkinter module (and tcl/tk) installation by including the proper
> directory into sys.path. Normally py2exe takes some care to *not* find
> modules or packages from a Python installation on the system.
> A little experimentation is probably needed, and hacking py2exe could
> maybe help. You can change this code (in py2exe\, near line
> 926)
>         header = struct.pack("<iii",
>                              self.optimize, # optimize
>                              0, # verbose
>                              0x0bad3bad,
>                              )
> into this
>         header = struct.pack("<iii",
>                              self.optimize, # optimize
>                              1, # verbose
>                              0x0bad3bad,
>                              )
> and the resulting executable will trace import statements.
> Thomas

More information about the Python-list mailing list