Problem to access Matlab API with Python

7 vues (au cours des 30 derniers jours)
Walter Reis
Walter Reis le 10 Août 2017
Réponse apportée : Swasti le 10 Juil 2025
Today I tried to use the Matlab API with python. I executed "python setup.py install" and got this output (seems ok):
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/matlab
copying dist/matlab/mlexceptions.py -> build/lib/matlab
copying dist/matlab/mlarray.py -> build/lib/matlab
copying dist/matlab/__init__.py -> build/lib/matlab
creating build/lib/matlab/engine
copying dist/matlab/engine/futureresult.py -> build/lib/matlab/engine
copying dist/matlab/engine/enginesession.py -> build/lib/matlab/engine
copying dist/matlab/engine/matlabengine.py -> build/lib/matlab/engine
copying dist/matlab/engine/__init__.py -> build/lib/matlab/engine
copying dist/matlab/engine/engineerror.py -> build/lib/matlab/engine
creating build/lib/matlab/_internal
copying dist/matlab/_internal/mlarray_utils.py -> build/lib/matlab/_internal
copying dist/matlab/_internal/mlarray_sequence.py -> build/lib/matlab/_internal
copying dist/matlab/_internal/__init__.py -> build/lib/matlab/_internal
running install_lib
copying build/lib/matlab/engine/_arch.txt -> /usr/local/lib/python2.7/site-packages/matlab/engine
running install_egg_info
Removing /usr/local/lib/python2.7/site-packages/matlabengineforpython-R2015b-py2.7.egg-info
Writing /usr/local/lib/python2.7/site-packages/matlabengineforpython-R2015b-py2.7.egg-info
When I start python and try to use the api, I get an error:
python
Python 2.7.12 (default, Aug 9 2017, 10:36:30)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matlab.engine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/matlab/engine/__init__.py", line 60, in <module>
raise EnvironmentError('The installation of MATLAB Engine for Python is '
EnvironmentError: The installation of MATLAB Engine for Python is corrupted. Please reinstall it or contact MathWorks Technical Support for assistance.
What went wrong? Do I need a separate license for this feature? I am using CentOS 6.9, 64 bit.
Kind regards Walter Reis
  1 commentaire
uchiha
uchiha le 20 Mar 2020
import matlab.engine
Traceback (most recent call last):
File "<ipython-input-1-754f7d50ef2a>", line 1, in <module>
import matlab.engine
ModuleNotFoundError: No module named 'matlab'
I got the above! :(

Connectez-vous pour commenter.

Réponses (1)

Swasti
Swasti le 10 Juil 2025
Try installing using the "python -m pip install ." command instead.
There is more information on the MATLAB Engine installation page here:

Catégories

En savoir plus sur Call MATLAB from Python dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by