Matlab Python Engine on MacOs

11 次查看(过去 30 天)
dmhd
dmhd 2021-12-20
I am trying to install the Matlab Python API on a MacOS Monterey 12.0.1 machine.
After I performed the "python3 setup.py install" command, which executes correctly, the package is in the correct site-package folder. When I start a session with "python3" and try to "import matlab.engine", I get the following error message:
>>> import matlab.engine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/lib/python3.9/site-packages/matlab/engine/__init__.py", line 77, in <module>
raise EnvironmentError(secondExceptionMessage)
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance:
First issue: No module named 'matlabengineforpython3_9'
Second issue: dlopen(/Applications/MATLAB_R2021b.app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_9.so, 0x0002): tried: '/Applications/MATLAB_R2021b.app/extern/engines/python/dist/matlab/engine/maci64/matlabengineforpython3_9.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/matlabengineforpython3_9.so' (no such file), '/usr/lib/matlabengineforpython3_9.so' (no such file)
How can I solve this?
Thank you in advance!

回答(1 个)

Anshika Chourasia
Anshika Chourasia 2022-2-25
编辑:Anshika Chourasia 2022-2-25
Hi,
According to my understanding, to resolve this issue please install the maci64 version of Python and use that with (maci64) MATLAB.
You should download one of the "Intel-only" installers on this page (https://www.python.org/downloads/macos/) to get "maci" versions of Python.
  2 个评论
Hangyu LIU
Hangyu LIU 2022-6-7
Hello Anshika,
I have tried the "Intel-only" python version, but I still have the same error as dmhd. Could you please help me?
Traceback (most recent call last):
File "/Users/lhy/Documents/python/matlab/mat_py.py", line 1, in <module>
import matlab.engine
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matlab/__init__.py", line 214, in <module>
from matlabmultidimarrayforpython import double, single, uint8, int8, uint16, \
ImportError: dlopen(/Applications/MATLAB_R2022a.app/extern/engines/python/../../../extern/bin/maci64/matlabmultidimarrayforpython.cpython-39-darwin.so, 0x0002): tried: '/Applications/Python 3.9/IDLE.app/Contents/Frameworks/matlabmultidimarrayforpython.cpython-39-darwin.so' (no such file), '/Applications/MATLAB_R2022a.app/extern/engines/python/../../../extern/bin/maci64/matlabmultidimarrayforpython.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Applications/Python 3.9/IDLE.app/Contents/Frameworks/matlabmultidimarrayforpython.cpython-39-darwin.so' (no such file), '/Applications/MATLAB_R2022a.app/extern/bin/maci64/matlabmultidimarrayforpython.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Call MATLAB from Python 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by