[python-win32] com server with py2exe fails to import standard module
Amit Upadhyay
upadhyay at gmail.com
Mon Jul 11 15:59:33 CEST 2005
Hi,
I have a COM server which is working fine on my development machine,
and I am trying to create a distributable using py2exe.
Setup.py file is something like this:
# setup.py
from distutils.core import setup
import py2exe
import sys
sys.argv.append("py2exe")
import mycomsvr
opts = {
"py2exe": {
"includes": "encodings,encodings.*"
}
}
setup(com_server=["mycomsvr"], options=opts)
and it successfully creates the COM server, and i register it using
regsvr32.exe, and I can then win32com.client.Dispatch from python
command line on my machine.
But when I tranfer it to some other machine, i can not create an
inproc instance of it using win32com.client.dispatch, it gives me:
Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
>>> w = win32com.client.Dispatch("webaroo.btdownloader")
Traceback (most recent call last):
File "boot_com_servers.py", line 44, in ?
File "btdownloader.pyc", line 14, in ?
File "socket.pyc", line 44, in ?
File "_socket.pyc", line 9, in ?
File "_socket.pyc", line 7, in __load
ImportError: DLL load failed: The specified module could not be found.
pythoncom error: ERROR: server.policy could not create an instance.
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 144, in C
reateInstance
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 202, in _
CreateInstance_
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 727, in c
all_func
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 717, in r
esolve_func
exceptions.AttributeError: 'module' object has no attribute 'BTDownloader'
pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005
)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, in
Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
lsctx)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in _
GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in _
GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
D_IDispatch)
pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)
>>> sys.path
['C:\\Documents and Settings\\webaroo\\Desktop\\amitu\\code\\client\\Windows\\br
anches\\b_p2p-multi\\P2P\\py-bittorrent\\dist\\library.zip']
>>> import socket
>>> w = win32com.client.Dispatch("webaroo.btdownloader")
pythoncom error: ERROR: server.policy could not create an instance.
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 144, in C
reateInstance
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 202, in _
CreateInstance_
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 727, in c
all_func
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 717, in r
esolve_func
exceptions.AttributeError: 'module' object has no attribute 'BTDownloader'
pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005
)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, in
Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
lsctx)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in _
GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in _
GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
D_IDispatch)
pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)
>>>
I have tried the same thing with Python2.4 too, but there I cant
import standard modules like socket, select etc either.
Please suggest me how to solve this problem, TIA.
--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9820-859-701
More information about the Python-win32
mailing list