Install Matlab engine for Python on MacBook M1

Hello guys,
I tried to install Matlab engine for Python on Macbook M1.
But when I try to import matlab.engine, I met some errors.
Anyone know how to fix this error?
Thank you in advance.
import matlab.engine
ImportError:
dlopen(/Applications/MATLAB_R2022a.app/extern/engines/python/../../../extern/bin/maci64/matlabmultidimarrayforpython.cpython-39-darwin.so, 0x0002):
tried: '/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/MATLAB_R2022a.app/extern/bin/maci64/matlabmultidimarrayforpython.cpython-39-darwin.so'
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

댓글 수: 4

Walter Roberson
Walter Roberson 2022년 6월 7일
편집: Walter Roberson 2022년 6월 7일
But are you using matlab under Rosetta or are you using the Open Beta of native implementation?
I am using the open beta of native implementation.
I have checked the above link.
This command works for me.
arch -x86_64 python3
But I have another question, can we set this python interpreter to Visual Studio Code so that I can debug the script.
For now, this command only works for the whole script.
Thank you for your feedback!
zhigang
zhigang 2022년 6월 29일
兄弟 你这句话I am using the open beta of native implementation. 是说你是在用原生适配m1的matlab软件还是在说python啊,我是rosseta2转译的matlab,在命令行执行arch -x86_64 python3报arch: posix_spawnp: python3: Bad CPU type in executable
我用的m1适配的MATLAB. 然后我是用的这个方法,最后是能运行了。你可以试试,看能不能行
Python 安装matlab
1.install python 3.8 under -x86_64
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias ibrew="arch -x86_64 /usr/local/bin/brew"
ibrew install python@3.8
2. Open Matlab:
cd (fullfile(matlabroot,'extern','engines','python'))
system('/usr/local/opt/python@3.8/bin/python3.8 setup.py install')
3. Open VS code:
Set python interpreter: /usr/local/opt/python@3.8/bin/python3.8

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

답변 (2개)

Shivam Lahoti
Shivam Lahoti 2022년 7월 3일

0 개 추천

You might be missing some steps in the process. you shall refer to this article and try again.
Steven Lord
Steven Lord 2022년 7월 3일

0 개 추천

If you are using the MATLAB R2022a Native Apple Silicon Platform Open Beta, one of the limitations listed on that page is "MATLAB Engine API for Python is not available."

카테고리

도움말 센터File Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 6월 7일

댓글:

2022년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by