By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,676 Members | 2,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,676 IT Pros & Developers. It's quick & easy.

win32com and numpy

P: 2
I am trying to use Excel as the front end for some python code.

I get an error (below) when trying to use a python code including numpy. If I don't import numpy I do not get the error. Is win32 somehow incompatible with numpy? I would appreciate any information regarding this issue.

Minimal example:

Expand|Select|Wrap|Line Numbers
  1. import win32com.server.register
  2. import pythoncom
  3. from numpy import mean
  5. class TimeSeriesManipulation:
  6.     _public_methods_ = [ 'SplitString']
  7.     _reg_progid_ = "PythonUtils.NumpyError"
  8.     _reg_clsid_ = "{08A4D1F8-0185-4692-BE40-4AD081DB90B1}"
  11.     def SplitString(self, val, item=None):
  12.         from string import split
  13.         if item != None: item = str(item)
  14.         return split(str(val), item)
  16. if __name__=='__main__':
  17.     print "Registering COM server..."
  18.     import win32com.server.register
  19.   win32com.server.register.UseCommandLine(TimeSeriesManipulation)
Expand|Select|Wrap|Line Numbers
  1. Sub tt()
  2. Set PythonUtils = CreateObject("PythonUtils.NumpyError")
  3. response = PythonUtils.SplitString("Hello from VB")
  4. For Each Item In response
  5. MsgBox Item
  6. Next
  7. End Sub
I get a run-time error ' -21474677259(80004005)':

Unexpected Python Error: Traceback (most recent call last):
File "C:\appl\python26\lib\site-packages\win32com\server\",
line 136 in CreateInstance
return retObj._CreateInstance_(clsid, reqIID)
File "C:\appl\python26\lib\site-packages\win32com\server\",
line 194, in _CreateInstance_
mvob = call func(classSpec)
Jan 17 '11 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 621
line 194, in _CreateInstance_
mvob = call func(classSpec)
This line in not in the code you posted so it is difficult to tell. Note that the Numpy that you install has to match the Python version. So there are separate Numpy packages for Python2.5, 2.6, and 2.7.
Jan 17 '11 #2

P: 2
To clarify:
Importing any function from numpy triggers an error when using the com object in excel. If I do not import anything from numpy, I do not get any errors.
Jan 18 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.