odd problem with makepy

Jim Kerr jim_kerr at agilent.com
Wed May 16 00:02:51 EDT 2001


  I'm having a strange problem with makepy. This isn't a show-stopper,
since I figured out a workaround, but I wish I knew what is going wrong.

  Here's the problem: I used makepy to generate a .pyc file for a registered
COM server. For a while, everything was fine. But after about two weeks
of bliss, Python began complaining that it couldn't find the server:

PythonWin 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) - see
'Help/About PythonWin' for further copyright information.
>>> import pythoncom
>>> from win32com.client import *
>>> na
=Dispatch("AgilentPNA835x.Application",clsctx=pythoncom.CLSCTX_LOCAL_SERVER)
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
  File "c:\python20\win32com\client\__init__.py", line 95, in Dispatch
    return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo,
UnicodeToString, clsctx)
  File "c:\python20\win32com\client\__init__.py", line 35, in __WrapDispatch
    klass = gencache.GetClassForCLSID(resultCLSID)
  File "c:\python20\win32com\client\gencache.py", line 131, in
GetClassForCLSID
    mod = GetModuleForCLSID(clsid)
  File "c:\python20\win32com\client\gencache.py", line 173, in
GetModuleForCLSID
    mod = GetModuleForTypelib(typelibCLSID, lcid, major, minor)
  File "c:\python20\win32com\client\gencache.py", line 205, in
GetModuleForTypelib
    return _GetModule(modName)
  File "c:\python20\win32com\client\gencache.py", line 456, in _GetModule
    mod = __import__("win32com.gen_py.%s" % fname)
ImportError: No module named 16D3C689-5F97-11D2-BC1F-0060B0B52EA7x0x1x1

... and sure enough, there is no module with that name. But there is one
almost like it, except
that the list digit is a 0, not a 1. If  I rerun makepy during this session:

>>> Generating to
c:\python20\win32com\gen_py\16D3C689-5F97-11D2-BC1F-0060B0B52EA7x0x1x0.py
>>> na =
Dispatch("AgilentPNA835x.Application",clsctx=pythoncom.CLSCTX_LOCAL_SERVER)
>>> na.Preset()   #  everything is beautiful from here...

  Now the COM interface works fine for the rest of the session, but the same
problem occurs at the next session.

  I finally just renamed my existing COM module to match the name that
Python was looking for, and everything seems OK now. What is it that
changed that caused this confusion in the first place?

  Thanks in advance for the help.

Jim Kerr
Agilent Technologies
Santa Rosa, CA  95403






More information about the Python-list mailing list