mathworks / jupyter-matlab-proxy

MATLAB Integration for Jupyter enables you to run MATLAB code in Jupyter Notebooks and other Jupyter environments. You can also open MATLAB in a browser directly from your Jupyter environment to use more MATLAB features.
Other
279 stars 36 forks source link

Incompatible with Matlab 2023b on Mac ARM #73

Closed HappySpring closed 11 months ago

HappySpring commented 11 months ago

I have Matlab 2023b installed on an M1 MacBook. And I got the following error messages after trying to start MatLAB from Jupiter Lab:

env: /Applications/MATLAB_R2023b.app/bin/maci64/path_per_install: No such file or directory
mkdir: /bin/maci64: Operation not permitted

There is a folder named maca64 at /Applications/MATLAB_R2023b.app/bin/ instead of the maci64. It looks like that a new architecture maca64 is introduced in Matlab 2023b, and it is not supported by the jupyter-matlab-proxy yet.

krisctl commented 11 months ago

Thank you for using jupyter-matlab-proxy, @HappySpring!

Can you please confirm that you are able to start this version of MATLAB outside of jupyter-server-proxy? I have observed this sort of error message stemming from MATLAB when there is a mismatched install. Example: An install of Intel-based MATLAB on an ARM-based machine and vice-versa.

With R2023b natively supporting Apple Silicon macOS, one can look to install respective MATLAB on a M1 Macbook by navigating to https://www.mathworks.com/downloads/web_downloads and Downloading for macOS (Apple Silicon).

Screenshot 2023-11-24 152028

Hope that helps!

HappySpring commented 11 months ago

Hi @krisctl,

I have checked that the matlab can be started normally outside of the jupyter-matlab-proxy. Here is some detailed information.

Snipaste_2023-11-24_21-56-29

-----------------------------------------------------------------------------------------
MATLAB Version: 23.2.0.2409890 (R2023b) Update 3
MATLAB License Number: XXXXXXXX
Operating System: macOS  Version: 14.1.1 Build: 23B81 
Java Version: Java 1.8.0_392-b08 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------
MATLAB                                                Version 23.2        (R2023b)
AUTOSAR Blockset                                      Version 23.2        (R2023b)
Aerospace Blockset                                    Version 23.2        (R2023b)
Aerospace Toolbox                                     Version 23.2        (R2023b)
Audio Toolbox                                         Version 23.2        (R2023b)
Automated Driving Toolbox                             Version 23.2        (R2023b)
Bioinformatics Toolbox                                Version 23.2        (R2023b)
Computer Vision Toolbox                               Version 23.2        (R2023b)
Control System Toolbox                                Version 23.2        (R2023b)
Curve Fitting Toolbox                                 Version 23.2        (R2023b)
DDS Blockset                                          Version 23.2        (R2023b)
Database Toolbox                                      Version 23.2        (R2023b)
Datafeed Toolbox                                      Version 23.2        (R2023b)
Deep Learning Toolbox                                 Version 23.2        (R2023b)
Econometrics Toolbox                                  Version 23.2        (R2023b)
Embedded Coder                                        Version 23.2        (R2023b)
Filter Design HDL Coder                               Version 23.2        (R2023b)
Financial Instruments Toolbox                         Version 23.2        (R2023b)
Financial Toolbox                                     Version 23.2        (R2023b)
Fixed-Point Designer                                  Version 23.2        (R2023b)
Fuzzy Logic Toolbox                                   Version 23.2        (R2023b)
GSW Oceanographic Toolbox                             Version 3.01        (R2011a)
Global Optimization Toolbox                           Version 23.2        (R2023b)
HDL Coder                                             Version 23.2        (R2023b)
Image Acquisition Toolbox                             Version 23.2        (R2023b)
Image Processing Toolbox                              Version 23.2        (R2023b)
Industrial Communication Toolbox                      Version 23.2        (R2023b)
Instrument Control Toolbox                            Version 23.2        (R2023b)
MATLAB Coder                                          Version 23.2        (R2023b)
MATLAB Compiler                                       Version 23.2        (R2023b)
MATLAB Compiler SDK                                   Version 23.2        (R2023b)
MATLAB Report Generator                               Version 23.2        (R2023b)
MATLAB Test                                           Version 23.2        (R2023b)
M_Map - mapping toolbox (Author: rich@eos.ubc.ca)     Version 1.4m        Feb     
Mapping Toolbox                                       Version 23.2        (R2023b)
Medical Imaging Toolbox                               Version 23.2        (R2023b)
Mixed-Signal Blockset                                 Version 23.2        (R2023b)
Model Predictive Control Toolbox                      Version 23.2        (R2023b)
NCTOOLBOX Tools for read-only access to Common ...    Version 1.1.1-13-g8582810++ 
Optimization Toolbox                                  Version 23.2        (R2023b)
Parallel Computing Toolbox                            Version 23.2        (R2023b)
Partial Differential Equation Toolbox                 Version 23.2        (R2023b)
Phased Array System Toolbox                           Version 23.2        (R2023b)
Predictive Maintenance Toolbox                        Version 23.2        (R2023b)
ROS Toolbox                                           Version 23.2        (R2023b)
Radar Toolbox                                         Version 23.2        (R2023b)
Reinforcement Learning Toolbox                        Version 23.2        (R2023b)
Requirements Toolbox                                  Version 23.2        (R2023b)
Risk Management Toolbox                               Version 23.2        (R2023b)
Robotics System Toolbox                               Version 23.2        (R2023b)
Robust Control Toolbox                                Version 23.2        (R2023b)
Sensor Fusion and Tracking Toolbox                    Version 23.2        (R2023b)
SerDes Toolbox                                        Version 23.2        (R2023b)
Signal Processing Toolbox                             Version 23.2        (R2023b)
Stateflow                                             Version 23.2        (R2023b)
Statistics and Machine Learning Toolbox               Version 23.2        (R2023b)
Symbolic Math Toolbox                                 Version 23.2        (R2023b)
System Composer                                       Version 23.2        (R2023b)
System Identification Toolbox                         Version 23.2        (R2023b)
Text Analytics Toolbox                                Version 23.2        (R2023b)
UAV Toolbox                                           Version 23.2        (R2023b)
Vehicle Dynamics Blockset                             Version 23.2        (R2023b)
Wavelet Toolbox                                       Version 23.2        (R2023b)

Thank you so much for your reply during the holidays and Happy Thanksgiving.

prabhakk-mw commented 11 months ago

Hi @HappySpring

I just downloaded, installed and activated MATLAB R2023b Update 4 on my M1 Mac and was able to successfully run MATLAB through the kernel.

image

These are the steps I took:

Step 1: Install MATLAB

  1. Download and install the Java Runtime from this link.

  2. Downloaded and installed MATLAB R2023b for MACA64 from the MathWorks website. image

  3. Started MATLAB R2023b from on the desktop and activated it with my online licensing credentials. (Your activation step may be different based on your license type)

  4. Ensured that I am able to repeatedly open it without it asking me for licensing information. This step ensures that I can use the Existing License Option when I start the MATLAB Kernel through Jupyter Lab.

  5. Added the newly downloaded MATLAB onto my system path using the following command on the system terminal: sudo ln -fs sudo ln -fs /Applications/MATLAB_R2023b.app/bin/matlab /usr/local/bin/matlab

  6. Verified that this change took effect using the following command on the system terminal: readlink -f `which matlab` Output:

    /Applications/MATLAB_R2023b.app/bin/matlab

Step 2: Setup Python environment

  1. I use miniconda to manage my python environments.

  2. Create a new python environment conda create -n r2023b python=3.10 -y

  3. Activate this conda environment called r2023b conda activate r2023b

  4. Install jupyter-matlab-proxy python -m pip install jupyter-matlab-proxy

  5. Verify that the packages were installed: python -m pip list | grep matlab Output:

    jupyter-matlab-proxy              0.10.0
    matlab-proxy                      0.10.0
  6. Activate my environment one more time, conda sometimes needs this to update the PATH after an installation. conda activate r2023b

  7. Verify that the jupyter lab I'm about to launch is from this environment: which jupyter Note how the jupyter executable is from the conda environment we r2023b that we previously created

    /Users/pbk/miniconda3/envs/r2023b/bin/jupyter
  8. Finally, we are ready to start Jupyter Lab: juptyer lab image

  9. Click on MATLAB Kernel, run a command, select Existing License and watch the magic: kernel-run-on-mac

  10. Final result: image

If I had to guess the issue on your machine might be setting the PATH as shown in Step 1. 5 sudo ln -fs sudo ln -fs /Applications/MATLAB_R2023b.app/bin/matlab /usr/local/bin/matlab

Hope this information helps!

HappySpring commented 11 months ago

Hi @prabhakk-mw,

Thank you for you detailed instructions.

Finally, I figured out what happened. I am able to fix the problem by installing another anaconda natively on apple silicon.

jupyter-matlab-proxy probably requires that python and Matlab should share the same architecture. For my case, both native Matlab and native python on apple silicon are required. I installed anaconda in 2021 when its native support for apple silicon had not arrived. The anaconda works normally on my Mac (at least for my research) but it is still for intel. Anaconda supports apple silicon natively about May 2022. However, it cannot update from an intel version to an apple silicon version automatically. I believe that is why the 'jupyter-matlab-proxy' is looking for 'maci': the python (included in anaconda) on my Mac is for intel platform.

Figured out what happened, I installed the latest anaconda supporting apple silicon natively, reinstalled jypyter lab and 'jupyter-matlab-proxy' in the new environment. Everything works after that.

prabhakk-mw commented 11 months ago

Happy to hear you've worked it out!