Borrar filtros
Borrar filtros

Cannot install matlab python engine API

53 visualizaciones (últimos 30 días)
Makis
Makis el 3 de Jul. de 2022
Comentada: Matthew Fall el 11 de En. de 2023
I am having trouble installing the python engine for my matlab 2022 version.
I go to "/Applications/MATLAB_R2022a.app/extern/engines/python" and run "python setup.py install"
Last lines of output look like this:
Extracting matlabengineforpython-R2022a-py3.8.egg to /opt/anaconda3/lib/python3.8/site-packages
matlabengineforpython R2022a is already the active version in easy-install.pth
/opt/anaconda3/lib/python3.8/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: R2022a is an invalid version and will not be supported in a future release
warnings.warn(
Installed /opt/anaconda3/lib/python3.8/site-packages/matlabengineforpython-R2022a-py3.8.egg
Processing dependencies for matlabengineforpython===R2022a
Finished processing dependencies for matlabengineforpython===R2022a
This looks fine. When I enter python3 and try to import the engine ("import matlab.engine"), i get:
>>> import matlab.engine
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/matlab/engine/__init__.py", line 46, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/opt/anaconda3/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'matlabengineforpython3_8'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/matlab/engine/__init__.py", line 65, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/opt/anaconda3/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'matlabengineforpython3_8'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/anaconda3/lib/python3.8/site-packages/matlab/engine/__init__.py", line 67, in <module>
raise EnvironmentError('Please reinstall MATLAB Engine for Python or contact '
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: No module named 'matlabengineforpython3_8'
  1 comentario
Matthew Fall
Matthew Fall el 11 de En. de 2023
I'm having the same issue for both Matlab R2021a and R2021b.

Iniciar sesión para comentar.

Respuestas (1)

Harimurali
Harimurali el 4 de Jul. de 2022
I understand that you are unable to install/use the MATLAB engine for Python.
Make sure that the following requirements are satisfied for installing MATLAB engine for Python:
If the above requirements are satisfied you can try the below steps:
1. Open MATLAB as administrator and run the following in the MATLAB command prompt:
>> cd (fullfile(matlabroot,'extern','engines','python'))
>> system('setup.py install')
This will install the MATLAB engine for Python.
2. Now start Python, import the module, and start the MATLAB engine:
import matlab.engine
eng = matlab.engine.start_matlab()
3. For exiting the matlab engine:
eng.quit()
Please refer the following MATLAB tutorial on using MATLAB engine.
  1 comentario
Matthew Fall
Matthew Fall el 11 de En. de 2023
It looks like Makis is already following these steps.

Iniciar sesión para comentar.

Categorías

Más información sobre Call MATLAB from Python en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by