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
283 stars 36 forks source link

Can't get matlab to work with Jupyter #39

Closed dfosterhill closed 1 year ago

dfosterhill commented 1 year ago

Hello.

Have tried to follow the instructions at the repo. Same with these here: http://jmlilly.net/jupyter-matlab. Matlab is indeed on my path. I have done the install of jupyter-matlab-proxy. If I then launch jupyter lab, the matlab option does not show up. If I instead launch jupyter notebook, and select 'new' from the dropdown at right, I see three matlab options:

If I pick 'kernel' I get a 'creating notebook failed' window with a large red 'forbidden' rectangle. The same happens with the other two matlab options.

Running Monterey on a m1 Mac.

Dave.

otavo commented 1 year ago

I have the same issue on Windows, "Error connecting to MATLAB. Check the status of MATLAB by clicking the "Open MATLAB" button. Retry after ensuring MATLAB is running successfully"

Does work with Anaconda y Jupyter 3.x

Python 3.x y jupyter 4.x Its Works!!!

krisctl commented 1 year ago

Hello @dfosterhill,

Thank you for trying out jupyter-matlab-proxy!

  1. The issue described as "The large red 'forbidden' rectangle" is related to an upstream issue with Jupyter Notebooks. More information related to this is described in jupyter/notebook#6702.

To workaround this issue, one could:

Use Jupyter Lab instead of Jupyter Notebook as shown below:

jupyter lab

If Jupyter Lab is not usable in your environment, one could also downgrade the version of jupyter-server as suggested in jupyter/notebook#6702 as follows:

pip install --upgrade 'jupyter-server<2.0.0'
  1. To diagnose the issue related to the MATLAB Kernel or Open MATLAB icons not showing on your Jupyter Lab interface, would you please try the steps mentioned in the troubleshooting guide, especially the section with the headline as If the integration is not showing up as an option to the dropdown box in the Jupyter notebook:

If the suggested solutions in the troubleshooting guide don’t work, then please share the output for the below commands:

# list the python environment
which python pip

# list the version of python & pip
python --version
pip --version

# list the packages installed 
python -m pip list | grep -E "jupyter|matlab-proxy|jupyter-matlab-proxy|notebook"

# list the jupyter executable
which jupyter

# list the matlab-proxy-app on path
which matlab-proxy-app

# list whether the server extensions are enabled
jupyter serverextension list

jupyter nbextension list

jupyter labextension list

It is sometimes possible that the Jupyter Lab environment requires one to explicitly activate extensions for use with Jupyter Lab, one can do it from the interface as shown below. After making these changes, be sure to restart jupyter lab to verify that they have taken effect.

image

  1. Finally, you also mention seeing 3 MATLAB options under New. Could you please share a screen shot showcasing this? It might be possible that the python environment that jupyter was launched from has multiple packages related to community kernels installed? Ideally, if one only has jupyter-matlab-proxy installed, then one should only see the following options under New:

image

  1. I use the following commands to create a fresh environment with the integration installed properly:

conda create -n freshEnv python=3.10 -y

conda activate freshEnv

python -m pip install jupyter-matlab-proxy jupyterlab

This reloads the environment to pick up the changes to your environment

conda activate freshEnv

ensure that the freshly installed executables are picked up by running which again:

which jupyter matlab-proxy-app

Example output on my machine:

/home/user/miniconda3/envs/freshEnv/bin/jupyter

/home/user/miniconda3/envs/freshEnv/bin/matlab-proxy-app



I hope this information helps fix these issues. 
Please do let me know if I can be of further assistance!
prabhakk-mw commented 1 year ago

@otavo

My guess is that MATLAB is occasionally taking longer to start in that environment. Could you please check the logs that are printed on the terminal to verify that MATLAB has started and has completed its startup sequence ?

You will see the MATLAB >> prompt on the terminal output when MATLAB has completed its startup sequence

Retrying the execution of the notebook cell after MATLAB has completed its startup sequence should resolve the error message.

PS: As of jupyter-matlab-proxy version 0.5.4 we increased this timeout to 120 seconds. If you are seeing this message before that time and are on a version of the proxy thats newer than 0.5.4 , please do create another issue to continue the investigation.

Thank you!

krisctl commented 1 year ago

Please feel free to create a new issue if this behavior is still observed.