Cannot start matlab engine in python
6 ビュー (過去 30 日間)
古いコメントを表示
The following code runs in MacOS on a remote machine with no display:
import matlab.engine
matlab_engine = matlab.engine.start_matlab()
It hangs for some time, mabe a minute or so then fails with the error stack:
Traceback (most recent call last):
File "m.py", line 5, in <module>
matlab_engine = matlab.engine.start_matlab()
File "/PythonEnv2/lib/python2.7/site-packages/matlab/engine/__init__.py", line 130, in start_matlab
eng = future.result()
File "/PythonEnv2/lib/python2.7/site-packages/matlab/engine/futureresult.py", line 67, in result
return self.__future.result(timeout)
File "/PythonEnv2/lib/python2.7/site-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future)
matlab.engine.EngineError: Connection to process with Exchange: " " was lost.
Any idea what can cause this.
My matlabengine package matlabengineforpython==9.13
Matlab itself: MATLAB_R2022b
The license is set up as environment variable MLM_LICENSE_FILE=...
Ping to all license servers specified in MLM_LICENSE_FILE works.
2 件のコメント
Navya Singam
2022 年 11 月 22 日
1) Is this issue happening sporadically?
2) Have you tried having a MATLAB session running and using the following command to Connect shared MATLAB session to MATLAB Engine for Python
import matlab.engine
eng = matlab.engine.connect_matlab()
Is the above command running without any issue?
J.
2023 年 2 月 17 日
Hi @Navya Singam I encountered the same error in the docker cloud environment. Due to the nature of my numerical experiments, I cannot start matlab session first and connect to it in python. Is there any workaround? (I also tried using background = True without any success.) Thanks!
回答 (1 件)
Rushikesh
2024 年 10 月 3 日
The issue may arise due to several factors such as licensing configuration problems, network issues, resource constraints on the server, or misconfigurations within the server environment.
Ensure that the licensing configuration is correct. You can try executing the ‘start_matlab’ function with the full path to the ‘network.lic’ file. This can be done in the server's command prompt.
%For example in python
eng = matlab.engine.start_matlab("-c /full/path/to/network.lic")
If you are using Docker, I recommend referring to the following MATLAB Central answer for a comprehensive guide on starting the MATLAB Engine within a Docker container:
0 件のコメント
参考
カテゴリ
Help Center および 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!