[Numpy-discussion] bus error in embedded numpy

Sturla Molden sturla@molden...
Fri Nov 13 13:48:50 CST 2009

Robin skrev:
> I had assumed when matlab unloads the mex function it would also
> unload python - but it looks like other dynamic libs pulled in from
> the mex function (in this case python and in turn numpy) aren't
> unloaded...
Matlab MEX functions are DLLs, Python interpreter is a DLL, NumPy .pyd 
files are DLLs... If you cannot unload Python or NumPy, you cannot 
unload MEX functions either. The same OS constraints apply.

If you are using Windows, I would recommend that you expose your NumPy 
code as a COM object using pywin32, and make a Matlab wrapper (ordinary 
.m file) that calls the COM object. If you are not using Windows, you 
could create an XMLRPC server in Python and call that using Matlab's 
built-in Java VM.

Or you can spawn a separate Python process from Matlab, and communicate 
using pipes or a tcp/ip socket (Matlab's Java or MEX).

There are many solutions that are easier than embedding Python in Matlab.


More information about the NumPy-Discussion mailing list