Corrupted installation of MATLAB Engine for Python

조회 수: 47 (최근 30일)
Ross
Ross 2015년 3월 31일
편집: Summer K.Rock 2022년 2월 28일
I'm trying to install the MATLAB Engine for Python on Windows 7.
When I run "python setup.py install" in the python engine directory the engine seems to build and install fine. But, when I try to import matlab.engine in Python I receive this error:
"EnvironmentError: The installation of MATLAB Engine for Python is corrupted. Please reinstall it or contact MathWorks technical Support for assistance."
I have tried reinstalling the engine to no avail. I'm using 64-bit MATLAB and 64-bit Python. Has anyone had a similar issue?
  댓글 수: 1
haojing
haojing 2016년 2월 17일
Hi Ross, Have you solved this problem? I am encountering exactly the same problem and I couldn't find a way to solve it.
The matlab engine used to work correctly but after I did a os upgrade it started to report such error. I've tried to reinstall the matlab engine but got no luck...

댓글을 달려면 로그인하십시오.

답변 (5개)

Bo Li
Bo Li 2015년 3월 31일
Would you try the verbose mode of Python?
C:\>python -vvv
>>>import matlab.engine
The output may have some useful info.
  댓글 수: 1
Ross
Ross 2015년 3월 31일
Unfortunately that didn't yield anything fruitful:
...
# trying C:\Anaconda\lib\site-packages\Pythonwin\matlabengineforpython2_7.pyw
# trying C:\Anaconda\lib\site-packages\Pythonwin\matlabengineforpython2_7.pyc
# trying C:\Anaconda\lib\site-packages\matlab\matlabengineforpython2_7.pyd
# trying C:\Anaconda\lib\site-packages\matlab\matlabengineforpython2_7.py
# trying C:\Anaconda\lib\site-packages\matlab\matlabengineforpython2_7.pyw
# trying C:\Anaconda\lib\site-packages\matlab\matlabengineforpython2_7.pyc
# trying C:\Program Files\MATLAB\R2014b\extern\engines\python\dist\matlab\engine\win64\matlabengineforpython2_7.pyd
# clear[1] _module_folder
# clear[1] _ver27
# clear[1] _ver
# clear[1] _envs
# clear[1] _env
# clear[1] _arch_filename
# clear[1] _arch_file
# clear[1] _arch
# clear[1] _PYTHONVERSION
# clear[1] _ver33
# clear[1] _engine_dir
# clear[1] _lines
# clear[1] _bin_dir
# clear[2] atexit
# clear[2] importlib
# clear[2] __package__
# clear[2] __doc__
# clear[2] __file__
# clear[2] sys
# clear[2] __name__
# clear[2] __path__
# clear[2] x
# clear[2] os
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\matlab\engine\__init__.py", line 61, 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.

댓글을 달려면 로그인하십시오.


Nagabhushan SN
Nagabhushan SN 2019년 10월 25일
If you're trying to install matlab engine in a conda environment, follow the below steps:
cd "matlabroot\extern\engines\python"
python setup.py install --prefix="installdir"
Eg
cd /Applications/MATLAB_R2015a.app/extern/engines/python
python setup.py install --prefix="/Users/user/anaconda/"
Now, matlab engine package is actually installed under the separate
anaconda3/lib/python3.6/site-package/matlab
So you need to manually move that matlab folder to the site-package folder your python is using. If you have multiple virtual envs, move it to the corresponding site-package folder of the virtual env you will run program.
Eg
anaconda3/env/my_env/lob/python3.6/site-packages/matlab
References:

Bo Li
Bo Li 2015년 3월 31일
Which version of CPython are you using? Would you try both CPython 2.7 and CPython 3.3 to see how they work?

Ross
Ross 2015년 3월 31일
I'm using Python 2.7 - I'd rather not go to 3.3 as I have some other Python dependencies that require 2.7.

Dave Bergstein
Dave Bergstein 2015년 4월 1일
This particular build of Python is not compatible with the MATLAB Engine for Python, which was developed for the reference Python implementation. Consider using one of the versions of Python described at the link below (including Python 2.7).
The link also includes requirements for building Python from source.
  댓글 수: 2
Ross
Ross 2015년 4월 1일
Which particular build are you referring to? Anaconda is just a package distribution; it uses CPython so I'm using reference Python 2.7.8....are you suggesting a different Python implementation or a different version?
I can try installing Python manually, but on Windows that's not the optimal way to go - Python package management in Windows is a pain.
Summer K.Rock
Summer K.Rock 2022년 2월 28일
편집: Summer K.Rock 2022년 2월 28일
Is there possible that copy "extern/engine/python" files to a pc without maltab installing, and use “pip install", could the APIEngine be installed?
Is matlab really necessary before install API engine?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by