フィルターのクリア

Cannot install matlab python engine API

52 ビュー (過去 30 日間)
Makis
Makis 2022 年 7 月 3 日
コメント済み: Matthew Fall 2023 年 1 月 11 日
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 件のコメント
Matthew Fall
Matthew Fall 2023 年 1 月 11 日
I'm having the same issue for both Matlab R2021a and R2021b.

サインインしてコメントする。

回答 (1 件)

Harimurali
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:
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 件のコメント
Matthew Fall
Matthew Fall 2023 年 1 月 11 日
It looks like Makis is already following these steps.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall MATLAB from Python についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by