pythoncom on Windows Server 2008

Mark Hammond skippy.hammond at gmail.com
Tue Nov 29 19:34:23 EST 2011


On 30/11/2011 11:12 AM, Nairn, Bruce wrote:
> Hi,
>
> I’m trying to move some code to a Windows Server 2008 machine. It runs
> on Windows 7 and XP, but fails on Windows Server 2008. The python
> installation is seemingly identical (python 2.6.4, 32 bit). The
> following replicates the problem:
>
> import pythoncom
>
> IDispatch = pythoncom.CoCreateInstance (‘OPC.Automation’, None,
> pythoncom.CLSCTX_SERVER, pythoncom.IID_IDispatch)
>
> On Windows 7 x64 or Windows XP x32:
>
> this returns an PyIDispatch object
>
> On Windows Server 2008 x64 this gives:
>
> com_error: (-2147221005, ‘Invalid class string’, None, None)
>
> Any suggestions would be appreciated!

The OPC.Automation object isn't installed on the Server 2008 box.  I'm 
not sure what this object is so can't advise on how to install it.  Note 
also that you will need the same "bittedness" of the object as Python 
itself has - ie, assuming a 32bit Python, you need the 32bit 
implementation of the COM object, or if a 64bit Python, you need the 
64bit COM object.  Note that both the 32 and 64bit versions of both will 
work fine on a 64bit version of Windows - you just need to make sure 
they match.

Mark



More information about the Python-list mailing list