Tinkering with py2exe

John Machin sjmachin at lexicon.net
Sun Dec 26 01:26:01 CET 2004

Ishwor wrote:
> Having coded 1.72kb python test file, i decided to convert it to .exe
> file using py2exe.
> Having succeded doing it, i found the need to distribute the whole
> directory including these files ?!!!???
> 26/12/2004  09:16 AM           203,096 library.zip
> 26/11/2004  09:16 AM         1,867,776 python24.dll
> 26/12/2004  09:16 AM            11,264 simpletable.exe
> 26/11/2004  09:16 AM             4,608 w9xpopen.exe
>                                     4 File(s)      2,086,744 bytes
> i assume w9xpopen.exe does the work around to run the code in

No, it is required to make the popen* functions work correctly on "w9x"
platforms (Windows 95, 98, & ME).

> python24.dll (which is massive 1.78mb!!)- has the Python VM i guess.
> what does the library.zip do??

(1) Aren't you curious enough to try peeking into it with WinZip or

(2) Perhaps you should have read all the way through the py2exe home

How does it work?
py2exe uses python's modulefinder to examine your script and find all
python and extension modules needed to run it. Pure python modules are
compiled into .pyc or .pyo files in a temporary directory. Compiled
extension modules (.pyd) are also found and parsed for binary

A zip-compatible archive is built, containing all python files from
this directory. Your main script is inserted as a resource into a
custom embedded python interpreter supplied with py2exe, and the
zip-archive is installed as the only item on sys.path.

> Currently to convert such a small script to exe why the nuances of

It's not compiling and linking, as with (say) C. It's packaging,
providing the minimum (more or less) bundle of resources that you can
distribute to users who want/need to run your script but
can't/don't/shouldn't have a full Python distribution. The overhead of
the pythonXY.dll etc can be spread over multiple scripts.

More information about the Python-list mailing list