This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Install MATLAB Engine API for Python

To start the MATLAB® engine within a Python® session, you first must install the engine API as a Python package. MATLAB provides a standard Python setup.py file for building and installing the engine using the distutils module. You can use the same setup.py commands to build and install the engine on Windows®, Mac, or Linux® systems.

Before you install, verify your Python and MATLAB configurations.

  • Check that your system has a supported version of Python and MATLAB R2014b or later. To check that Python is installed on your system, run Python at the operating system prompt.

  • Add the folder that contains the Python interpreter to your path, if it is not already there.

  • Find the path to the MATLAB folder. Start MATLAB and type matlabroot in the command window. Copy the path returned by matlabroot.

To install the engine API, choose one of the following.

  • At a Windows operating system prompt —

    cd "matlabroot\extern\engines\python"
    python setup.py install
    

    You might need administrator privileges to execute these commands.

  • At a macOS or Linux operating system prompt —

    cd "matlabroot/extern/engines/python"
    python setup.py install
    

    You might need administrator privileges to execute these commands.

  • At the MATLAB command prompt —

    cd (fullfile(matlabroot,'extern','engines','python'))
    system('python setup.py install')
  • Use one of the nondefault options described in Install MATLAB Engine API for Python in Nondefault Locations.

Note

You must call this python command in the specified folder.

Related Topics

External Websites