Py2exe and WMI module

Tim Golden tim.golden at
Mon Jan 26 17:53:12 CET 2004

>From: nekiv at [mailto:nekiv at]
>I'm having a problem when I try to make a standalone installation of a
>Python program using Tim Goldens WMI-module.  The py2exe produce the
>exe-file as expected, but it fails to execute.

Well, I've tried to play with wmi-py2exe myself for the first
time, with mixed results. If I understand the idea, what you
do is this:

Use the makepy generator to generate gen_py support for the
Microsoft WMI 1.1 Scripting Library. This will result in a
proxy module in %TEMP%\gen_py\2.3 (for recent win32all releases)
called something like:

Note the x0x1x1 at the end.

You then need a setup script such as this one:

from distutils.core import setup
import py2exe
setup (
  options = {
    "py2exe": {
      "typelibs": [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 1)]

That "typelibs" line is made up from the proxy string 
effectively split like this:

"565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1".split ("x")

It's not exactly that, but you can work it out for yourself. In
fact, the first bit is the CLSID, and the others are the LCID,
major and minor numbers from within

<... snipped from Python proxy module ...>

CLSID = IID('{565783C6-CB41-11D1-8B02-00600806D9B6}')
MajorVersion = 1
MinorVersion = 1
LibraryFlags = 8
LCID = 0x0


Given a module, say,, which imports the wmi module,
you can now run

c:\python23\python py2exe

in the usual way to create an exe.

After that, you're even more on your own than you were before.


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the Python-list mailing list