Can not connect to Matlab session from Python, I can start matlab engine but can not connect from python
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In python:
import matlab.engine
print(matlab.engine.find_matlab())
('MATLAB_9012',)
eng = matlab.engine.connect_matlab('MATLAB_9012')
eng.sqrt(4.0)
EngineError Traceback (most recent call last) Cell In[132], line 1----> 1 eng = matlab.engine.connect_matlab('MATLAB_9012') 2 eng.sqrt(4.0) File ~\anaconda3\Lib\site-packages\matlab\engine\__init__.py:201, in connect_matlab(name, **kwargs) 199 future = FutureResult(name=name, attach=True) 200 if not background: --> 201 eng = future.result() 202 return eng 203 else: File ~\anaconda3\Lib\site-packages\matlab\engine\futureresult.py:62, in FutureResult.result(self, timeout) 59 if timeout < 0: 60 raise TypeError(pythonengine.getMessage('TimeoutCannotBeNegative')) ---> 62 return self.__future.result(timeout) File ~\anaconda3\Lib\site-packages\matlab\engine\matlabfuture.py:87, in MatlabFuture.result(self, timeout) 84 else: 85 raise TimeoutError(pythonengine.getMessage('LaunchMatlabTimeout')) ---> 87 handle = pythonengine.getMATLAB(self._future) 88 eng = MatlabEngine(handle) 89 self._matlab = eng EngineError: Unable to connect to MATLAB session 'MATLAB_9012'.
-----------------------------------------------------------------------------------
If I do this:
import matlab.engine
# Start the MATLAB engine
eng = matlab.engine.start_matlab()
# Check if the engine is running
print("MATLAB Engine started:", eng)
MATLAB Engine started: <matlab.engine.matlabengine.MatlabEngine object at 0x0000024483C419A0>
I can start Matlab engine but I can not connect to a running Matlab session????
Antworten (1)
Siehe auch
Kategorien
Mehr zu Call MATLAB from Python finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!