matlab engine for python--systemerror from en.quit()

6 次查看(过去 30 天)
Hello, When I try to execute eng.quit() using the matlab engine for python (which is overall nice), i get this annoying Python error: --------------------------------------------------------------------------- SystemError Traceback (most recent call last) /Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where) 202 else: 203 filename = fname --> 204 _builtin_.execfile(filename, *where)
/Users/samuelheroy/kccperc_rods.py in module() 23 print('The time it takes to run this program is') 24 print(time.clock()-t0) ---> 25 eng.exit()
/Users/samuelheroy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matlab/engine/matlabengine.pyc in exit(self) 244 """ 245 if self._matlab is not None: --> 246 pythonengine.closeMATLAB(self._matlab) 247 self.__dict__["_matlab"] = None 248
SystemError: MATLAB process can not be terminated.
It's not affecting my ability to run the code, but its presence in the output is rather annoying. Does anyone know why I'm getting this, or have a fix/workaround?

回答(1 个)

Sarah Palfreyman
Sarah Palfreyman 2014-10-29
Hi Sam,
Can you post your Python code?
Regarding the "SystemError: MATLAB process can not be terminated." is it possible that the engine was already stopped when you called quit()?
Quiting the MATLAB engine twice ...
>>> eng=matlab.engine.start_matlab() >>> eng.eval('exit', nargout=0) >>> eng.exit()
produces a very similar error message ...
matlabengine.py", line 246, in exit pythonengine.closeMATLAB(self._matlab) SystemError: MATLAB process can not be terminated.
  1 个评论
sanlin ke
sanlin ke 2023-8-25
编辑:sanlin ke 2023-8-25
Hi, I'm having the same problem.
Exception ignored in: <function MatlabEngine.__del__ at 0x0000017B23790DC0>
Traceback (most recent call last):
File "C:\Python\Python39\lib\site-packages\matlab\engine\matlabengine.py", line 250, in __del__
self.exit()
File "C:\Python\Python39\lib\site-packages\matlab\engine\matlabengine.py", line 232, in exit
pythonengine.closeMATLAB(self.__dict__["_matlab"])
SystemError: MATLAB process cannot be terminated.
Could you help reply? Thanks!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by