With the publishing of the pre-release MATLAB R2023b Apple Silicon native support, MATLAB Engine for Python can be installed via 'setup.py' 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
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.
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
homebrewand set up well.
The solution can be found from stackoverflow discuss.
open ~/.zshrcand add the following line to the end of the file.
browis the alias for
ibis the alias for
- Add an alias to switch between
- Install python via
Wait for the installation.
MATLAB Engine for Python.
Start from R2022b, you can install matlab engine via
- 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.
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
Then, update all packages including
pipin the virtual environment. You should have matlabengine installed in the virtual environment since you did it in the previous step.
Finally, you can import
matlab.engineand test it in Pycharm with Python Console.
The output should return
- Author:PENG Jiaxin
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!