Cannot install matlab python engine API
조회 수: 35 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Harimurali
2022년 7월 4일
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:
- A licensed version of MATLAB installed on your system.
- Python version compatible with MATLAB is installed. Refer Python versions compatible with MATLAB.
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()
댓글 수: 1
참고 항목
카테고리
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!