Install MATLAB-Engine for Python on Apple Silicon M-series chip
00 min
Jan 1, 2023
Aug 26, 2023
With the publishing of the pre-release MATLAB R2023b Apple Silicon native support, MATLAB Engine for Python can be installed via '' script in the engine folder.
You can use the following code:
The output will be:
Then you can check whether the engine installed successfully by running the following code:
The output should be 2.0.
Following above process can help you to install the engine. However, I am not sure whether it is stable or not. You can try it by yourself. If you find any problem, you can try to contact MATLAB support team.

Issues with MATLAB Engine on Apple Silicon

Since I switched to appli silicon and installed MATLAB R2022a and R2022b, MATLAB Engine for Python is invalid.
To solve the issue, we need to install Python via arch-x86_64. Before that, I assume you have already installed native homebrew and set up well.

Install Homebrew via x86_64 platform

The solution can be found from stackoverflow discuss.
  1. Install homebrew via arch-x86_64 platform
  1. Add arch-x86_64 to PATH in ~/.zshrc. by open ~/.zshrc and add the following line to the end of the file.
The brow is the alias for brew and ib is the alias for arch-x86_64.
  1. Add an alias to switch between arch-x86_64 and arch-arm64 platform

Install Python via x86_64 platform

  1. Install python via arch-x86_64 platform homebrew.
Wait for the installation.

Install MATLAB Engine for Python

  1. Install MATLAB Engine for Python.
Start from R2022b, you can install matlab engine via pip.
  1. Test the installation.
Wait for the starting of the MATLAB engine.
Warning: In this step, you may have an error return:
Until now, I did not find any solution to solve this issue if running all code in Terminal.

Run MATLAB Engine for Python in Pycharm

However, I find that I can use MATLAB Engine in Pycharm by virtual environment.
First, you need to create a virtual environment in Pycharm with x86_64 platform Python3.
notion image
Then, update all packages including pip in the virtual environment. You should have matlabengine installed in the virtual environment since you did it in the previous step.
notion image
Finally, you can import matlab.engine and test it in Pycharm with Python Console.
The output should return 5.

  • Twikoo
  • Giscus