Skip to main content

Jupyter Server Proxy for MATLAB

Project description

MATLAB Integration for Jupyter


GitHub Workflow Status PyPI badge codecov

Copyright (c) 2021 The MathWorks, Inc. All rights reserved.


The MATLAB Integration for Jupyter enables you to access MATLAB in a web browser from your Jupyter environment.

jupyter-matlab-proxy is a Python® package based on the following packages.

Package Description
matlab-proxy Provides infrastructure to launch MATLAB and connect to it from a web browser.
jupyter-server-proxy Extends Jupyter environments to launch MATLAB as an external process alongside the notebook server. For more information see GUI Launchers.

NOTE: This package currently, does not provide a kernel level integration with Jupyter. (under active development)

To report any issues or suggestions, see the Feedback section.


Requirements

This package has the same requirements as its dependencies:

Installation

PyPI

This repository can be installed directly from the Python Package Index.

python -m pip install jupyter-matlab-proxy

If you want to use this integration with JupyterLab®, ensure that you have JupyterLab installed on your machine by running the following command:

python -m pip install jupyterlab

You should then install jupyterlab-server-proxy JupyterLab extension. To install the extension, use the following command:

jupyter labextension install @jupyterlab/server-proxy

Building From Sources

git clone https://github.com/mathworks/jupyter-matlab-proxy.git

cd jupyter-matlab-proxy

python -m pip install .

Usage

Upon successful installation of jupyter-matlab-proxy, your Jupyter environment should present options to launch MATLAB.

  • Open your Jupyter environment by starting jupyter notebook or lab

    # For Jupyter Notebook
    jupyter notebook
    
    # For Jupyter Lab
    jupyter lab 
    
  • If you are using Jupyter Notebook (on the left in figure below), on the New menu, select MATLAB. If you are using JupyterLab (on the right in figure below), select the MATLAB icon on the launcher.

  • If prompted to do so, enter credentials for a MathWorks account associated with a MATLAB license. If you are using a network license manager, change to the Network License Manager tab and enter the license server address instead. To determine the appropriate method for your license type, consult MATLAB Licensing Info.

  • Wait for the MATLAB session to start. This can take several minutes.

  • To manage the MATLAB integration for Jupyter, click the tools icon shown below.

  • Clicking the tools icon opens a status panel with buttons like the ones below:

    The following options are available in the status panel (some options are only available in a specific context):

    Option Description
    Start MATLAB Session Start your MATLAB session. Available if MATLAB is stopped.
    Restart MATLAB Session Restart your MATLAB session. Available if MATLAB is running or starting.
    Stop MATLAB Session Stop your MATLAB session. Use this option if you want to free up RAM and CPU resources. Available if MATLAB is running or starting.
    Sign Out Sign out of MATLAB. Use this to stop MATLAB and sign in with an alternative account. Available if using online licensing.
    Unset License Server Address Unset network license manager server address. Use this to stop MATLAB and enter new licensing information. Available if using network license manager.
    Feedback Send us feedback. This action opens your default email application.
    Help Open a help pop-up for a detailed description of the options.

Limitations

This package supports the same subset of MATLAB features and commands as MATLAB® Online, except there is no support for Simulink® Online. Click here for a full list of Specifications and Limitations for MATLAB Online.

If you need to use functionality that is not yet supported, or for versions of MATLAB earlier than R2020b, you can use the alternative MATLAB Integration for Jupyter using VNC.

Integration with JupyterHub

To use this integration with JupyterHub®, you must install the jupyter-matlab-proxy Python package in the Jupyter environment launched by your JupyterHub platform.

For example, if your JupyterHub platform launches Docker containers, then install this package in the Docker image used to launch them.

A reference architecture that installs jupyter-matlab-proxy in a Docker image is available at: Use MATLAB Integration for Jupyter in a Docker Container.

Troubleshooting

In the environment that you have installed the package:

  • Verify if the MATLAB executable is discoverable (ie. if it is in the PATH)

    $ which matlab
    /usr/local/bin/matlab
    
  • Check if their Python version is 3.6 or higher

    $ python --version
    Python 3.7.3
    
  • Ensure that matlab-proxy-app and the jupyter executables are in the same environment as the python executable. For example if youare using VENV to manage your python environments:

    $ which python
    /home/user/my-project/packages/.venv/bin/python
    
    $ which matlab-proxy-app
    /home/user/my-project/packages/.venv/bin/matlab-proxy-app
    
    $ which jupyter
    /home/user/my-project/packages/.venv/bin/jupyter
    

    Notice that matlab-proxy-app, jupyter and the python executable are in the same parent directory, in this case it is: /home/user/my-project/packages/.venv/bin

  • Ensure that you are launching jupyter notebook using the same executable as listed above.

  • Ensure that all three packages are installed in the same python environment

    # Pipe the output of pip freeze and grep for jupyter, matlab-proxy and jupyter-matlab-proxy.
    # All three packages should be highlighted in the output.
    # If you don't see anyone of them, then either the packages missing in the output have been installed
    # in a different python environment or not installed at all.
    $ pip freeze | grep -E "jupyter|matlab-proxy|jupyter-matlab-proxy"
    
  • If the integration is not showing up as an option to the dropdown box in the Juptyer notebook:

    #Run the following commands and verify that you are able to see similar output:
    
    $ jupyter serverextension list
    config dir: /home/user/anaconda3/etc/jupyter
        jupyter_server_proxy  enabled
        - Validating...
        jupyter_server_proxy  OK
        jupyterlab  enabled
        - Validating...
        jupyterlab 2.2.6 OK
    
    $ jupyter nbextension list
    Known nbextensions:
    config dir: /home/user/anaconda3/etc/jupyter/nbconfig
        notebook section
        jupyter-js-widgets/extension  enabled
        - Validating: OK
        tree section
        jupyter_server_proxy/tree  enabled
        - Validating: OK  $ pip freeze | grep -E "jupyter|matlab-proxy|jupyter-matlab-proxy"
    
    # IF the server does not show up in the commands above, install:
    $ pip install jupyter_contrib_nbextensions
    

Feedback

We encourage you to try this repository with your environment and provide feedback. If you encounter a technical issue or have an enhancement request, create an issue here or send an email to jupyter-support@mathworks.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter-matlab-proxy-0.4.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

jupyter_matlab_proxy-0.4.0-py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page