Calling Mex File inside a Matlab Engine Call from Python, matlab.eng​ine.Engine​Error: MATLAB function cannot be evaluated, SystemError: MATLAB process cannot be terminated

I have an imaging pipeline that is in Python, this pipelline needs to call a scripts Matlab doing wavelet filtering. However the Matlab code I have is calling some compiled C code. I know it seems completely absurd but for now I have to go this way.
Is it possible to call a C mex file through Matlab called by python with the Matlab engine?
Thanks.
Here is the full error message I get:
File "/PATH/TO/PYTHON/Script.py", line 93, in <module>
piw_reslice(s['pet'], 6, 1, 24)
File "/PATH/TO/PYTHON/module.py", line 14, in piw_reslice
nargout=0)
File "PATH/TO/envs/pysep3/lib/python3.7/site-packages/matlab/engine/matlabengine.py", line 71, in __call__
_stderr, feval=True).result()
File "PATH/TO/envs/pysep3/lib/python3.7/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
File "PATH/TO/envs/pysep3/lib/python3.7/site-packages/matlab/engine/fevalfuture.py", line 82, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
matlab.engine.EngineError: MATLAB function cannot be evaluated
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "PATH/TO/envs/pysep3/lib/python3.7/site-packages/matlab/engine/__init__.py", line 193, in __exit_engines
eng().exit()
File "PATH/TO/envs/pysep3/lib/python3.7/site-packages/matlab/engine/matlabengine.py", line 232, in exit
pythonengine.closeMATLAB(self.__dict__["_matlab"])
SystemError: MATLAB process cannot be terminated.

4 个评论

hello, do you solve this problem. i have the same problem, can you please help me.
In my case it so happened that the problem was comming from the mex compilation itself. On my workspace the gcc default version for matlab compatibility was matlab 2017 so switching to this version of matlab solved my issue.
Tharks for your answer。I have slove this problem by sharing this matlab session with python.
I also have this question, can you please tell me how do you share the matlab session with python?

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Call MATLAB from Python 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by