I installed a clean copy of Python 2.5, pywin32 and PyGreSQL and it works. I'll have to figure out what broke with my 2.6 install.
Thanks for letting me scribble here. "Richard Whidden" <n...@arealemailaddress.org> wrote in message news:002a58fa$0$25248$c3e8...@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 > -- http://mail.python.org/mailman/listinfo/python-list