[python-win32] Dynamic dispatching and AttributeErrors,

Mark Hammond mhammond at skippinet.com.au
Thu Nov 18 22:35:50 CET 2010


On 18/11/2010 5:45 PM, Brian Merrell wrote:
>     ob = win32com.client.Dispatch(...)
>
>  >>ob
> <COMObject ConcordanceServer>
>  >>print ob
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line
> 197, in __str__
>      return str(self.__call__())
>    File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line
> 182, in __call__
>      return
> self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
> pywintypes.com_error: (-2147319779, 'Library not registered.', None, None)

That is very strange - it seems at least one type library needed isn't 
registered - although the fact makepy ran at all means at least one type 
library *is* registered.

>     A traceback would be useful here - if the object really is a dynamic
>     object, an AttributeError implies that the object itself also
>     doesn't think the attribute exists (as dynamic objects ask the
>     object for the attribute before raising an AttributeError).
>
> I am calling a method listed in the gen_py file so I am not sure how the
> attribute could not exist (I was careful about capitalization.  I can
> post/send a very abbreviated version of this file (just the wrapper
> stuff and a single method) if it would help.

That is why a traceback would be useful for the attribute error - but it 
sounds like the object you are calling isn't a makepy instance, just a 
regular dynamic dispatch object, so the makepy class isn't being used. 
That is what should have been addressed by explicitly wrapping it in the 
class, but for reasons I can't explain that generates the "type lib not 
registered" error.

I'm afraid I'm out of ideas - can you try reinstalling the COM object, 
or asking for help from the author of that object?

Cheers,

Mark


More information about the python-win32 mailing list