pythoncom -- ImportError: DLL load failed - Update

Richard Whidden not at arealemailaddress.org
Fri Apr 24 22:14:55 CEST 2009


By including the following DLLs on a Windows 2000 image I have running 
Python 2.5, my little sample app works...
comerr32.dll     krb5_32.dll      libintl-8.dll    python26.dll
gssapi32.dll     libeay32.dll     libpq.dll        ssleay32.dll
k5sprt32.dll     libiconv-2.dll   python25.dll
msvcm90.dll   msvcp90.dll   msvcr90.dll

However, on my WinXP development machine (running Python 2.6) this doesn't 
work--Instead I receive a message,
"An application has made an attempt to load the C runtime library 
incorrectly..."  Once I remove the msvc* files, it goes back to the original 
problem...

Argh.

The msvc* dlls are in an odd place: 
C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_6f74963e

I've tried including that directory to my system path too, of course.



"Richard Whidden" <not at arealemailaddress.org> wrote in message 
news:002a58fa$0$25248$c3e8da3 at news.astraweb.com...
> I've sniffed around for a solution to this problem but I can't find 
> anything.
>
> The simple COM example in the "Programming on Win32" O'Reilly book works 
> fine.  However, as soon as I add 'import pgdb' to the object, chaos ensues 
> promply.
>
> Here's what I did.
>
> Step 1, write this:
> foo.py ------
> # print pythoncom.CreateGuid()
> import pgdb
> class PythonUtilities:
>  _public_methods_ = [ 'SplitString']
>  _reg_progid_ = "FooFoo.Utilities"
>  _reg_clsid_ = "<Run pythoncom.CreateGuid() from a python prompt and 
> insert value here."
>
>  def SplitString(self, val, item=None):
>    import string
>    if item !=None: item = str(item)
>    return string.split(str(val), item)
>
> if __name__=='__main__':
>  print "Registering COM server"
>  import win32com.server.register
>  win32com.server.register.UseCommandLine(PythonUtilities)
> ----- End of foo.py
>
> Step 2, run 'python foo.py'.
>
> Step 3, write this:
> test.vbs ----- 
> set o = CreateObject("FooFoo.Utilities")
> ------- End of test.vbs
>
> Step 4, run 'cscript /nologo test.vbs'
>
> Step 5, watch it fail.
>
> Error ----------
> C:\devel\blip\test.vbs(1, 1) (null): Unspecified error
>
> pythoncom error: ERROR: server.policy could not create an instance.
>
> Traceback (most recent call last):
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 136, 
> in CreateInstance
>    return retObj._CreateInstance_(clsid, reqIID)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 194, 
> in _CreateInstance_
>    myob = call_func(classSpec)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 727, 
> in call_func
>    return resolve_func(spec)(*args)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 716, 
> in resolve_func
>    module = _import_module(mname)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 735, 
> in _import_module
>    __import__(mname)
>  File "C:\devel\blip\foo.py", line 4, in <module>
>    class PythonUtilities:
>  File "C:\devel\blip\foo.py", line 5, in PythonUtilities
>    import pgdb
>  File "C:\Python26\Lib\site-packages\pgdb.py", line 66, in <module>
>    from _pg import *
> ImportError: DLL load failed: The specified module could not be found.
> pythoncom error: Unexpected gateway error
>
> Traceback (most recent call last):
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 136, 
> in CreateInstance
>    return retObj._CreateInstance_(clsid, reqIID)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 194, 
> in _CreateInstance_
>    myob = call_func(classSpec)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 727, 
> in call_func
>    return resolve_func(spec)(*args)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 716, 
> in resolve_func
>    module = _import_module(mname)
>  File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 735, 
> in _import_module
>    __import__(mname)
>  File "C:\devel\blip\foo.py", line 4, in <module>
>    class PythonUtilities:
>  File "C:\devel\blip\foo.py", line 5, in PythonUtilities
>    import pgdb
>  File "C:\Python26\Lib\site-packages\pgdb.py", line 66, in <module>
>    from _pg import *
> ImportError: DLL load failed: The specified module could not be found.
> pythoncom error: CPyFactory::CreateInstance failed to create instance. 
> (80004005)
> ---------  End of Error
>
> I've tried a few things.  If I import foo.py into a python script, it 
> works fine.  It only fails if I try things via COM.
>
> I've run depends.exe.  Everything can see everything else.
>
> I've moved libpq.dll to \windows\system32, \scriptpath, \postgres\lib, 
> \postgres\bin... Probably other places too to no avail.
>
> I'm sure I've tried other things, I just can't think of them right now.  I 
> have this sickening feeling in my gut that the solution is so obvious that 
> a blind and dead person would have spotted the solution before me.
>
> Anyway, if anyone has an idea (or a link to an idea) please let me know.
>
> Thanks,
> Richard Whidden
> 





More information about the Python-list mailing list