Installing matlab.engine API for Python in linux-based HPC
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to use the HPC to accelerate my python-controlled Simulink.
Therefore, I have to install the matlab.engine on the HPC first.
Since my university's HPC only provides the Matlab-R2020a, so I have to use Python 2.7/ 3.6/ 3.7.
So I did the following steps. First I used Python 2.7
- cd /home/ViperAppsFiles/matlab/2020a/extern/engines/python/
- python setup.py build --build-base = /home/users/.cache install --prefix=/home/users/software
Now the whole module is built in software folder. Then I change the PYTHONPATH by:
export PYTHONPATH = /home/user/software/lib/python2.7/site-packages:$PYTHONPATH
But it reports the fault when I tried to call import matlab.engine:
Please contact MathWorks Technical Support for assistance:
Details: need more than 3 values to unpack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/software/lib/python2.7/site-packages/matlab/__init__.py", line 209, in <module>
raise RuntimeError('unable to read {}'.format(get_arch_filename()))
RuntimeError: unable to read /home/user/software/lib/python2.7/site-packages/matlab/engine/_arch.txt
>>> RuntimeError: unable to read /home/user/software/lib/python2.7/site-packages/matlab/engine/_arch.txt
File "<stdin>", line 1
RuntimeError: unable to read /home/user/software/lib/python2.7/site-packages/matlab/engine/_arch.txt
^
SyntaxError: invalid syntax
And according to this method, the module only support 2.7, 3.8, 3.9, which 3.8 and 3.9 is incapable of cooperating with matlab/R2020a.
0 comentarios
Respuestas (1)
Ashu
el 27 de En. de 2023
Hi Jianing,
To install Python Engine you have to follow these steps -
1. Find the matlabroot by executing the following command at the MATLAB command window
matlabroot
2. change directory to :
<matlabroot>\extern\engines\python
3. Execute the follwing command with admin privilege :
python setup.py install
I would suggest you to use plain command like mentioned above, but if needed try the following for your use case:
python setup.py build -b <somedir> install
Then export the path if needed.
For more information on matlab.engine for python you can refer
https://www.mathworks.com/help/matlab/matlab_external/get-started-with-matlab-engine-for-python.html
Regards
Ashutosh
2 comentarios
Ver también
Categorías
Más información sobre Call MATLAB from Python en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!