0

I want to call matlab from python using mlab. When I do the following

from mlab.releases import R2012a as matlab

I get the following error:

Exception AssertionError: AssertionError() in <bound method MlabWrap.__del__ of <mlab.mlabwrap.MlabWrap object at 0x000000000A7AC9B0>> ignored
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda\lib\site-packages\mlab\releases.py", line 125, in __getattr__
return self.instances[name]
  File "C:\Anaconda\lib\site-packages\mlab\releases.py", line 63, in __getitem__
self[k] = self.get_mlab_instance(k)
  File "C:\Anaconda\lib\site-packages\mlab\releases.py", line 87, in get_mlab_instance
instance = MlabWrap()
  File "C:\Anaconda\lib\site-packages\mlab\mlabwrap.py", line 405, in __init__
self._session = mlabraw.open()
  File "C:\Anaconda\lib\site-packages\mlab\mlabraw.py", line 44, in open
ret.open()
  File "C:\Anaconda\lib\site-packages\mlab\matlabcom.py", line 62, in open
self.client = win32com.client.Dispatch('matlab.application')
  File "C:\Anaconda\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Anaconda\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Anaconda\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221008, 'CoInitialize wurde nicht aufgerufen.', None, None)

The displayed error at the end says in German 'CoInitialize was not called'. I have no idea what to do. Any help to trace the error would be much appreciated.

EDIT: I have MATLAB R2012a 64bit installed on Windows 7 64bit.

Community
  • 1
  • 1
user3820991
  • 2,310
  • 5
  • 23
  • 32
  • why are saying `as matlab`? Are you trying to assign the import R2012a as a variable? Can you post your code? Did you download and install mlab module? did you place it in the proper directory? – awbemauler Aug 06 '15 at 16:44
  • `as matlab` is not the problem here. It's just there so that I can call matlab functions like this `matlab.sum()` later in the script. I could try to call matlab without the `mlab` module just using the `win32com` modul. Trying `m = win32com.client.Dispatch('matlab.application')` as the `mlab` modual actually does gives the same error as above. I tried different ProgIDs suggested by Mathwork [here](http://de.mathworks.com/help/matlab/matlab_external/introduction_brd0vd4-1.html), but that does not seem to be the problem either. – user3820991 Aug 07 '15 at 09:50

0 Answers0