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.
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, execute the following commands at
the operating system prompt, where matlabroot
is
the path to the MATLAB folder. You might need administrator privileges
to execute these commands. Alternatively, use one of the nondefault
options described in Install MATLAB Engine API for Python in Nondefault Locations.
On Windows systems —
cd "matlabroot\extern\engines\python" python setup.py install
On Mac or Linux systems —
cd "matlabroot/extern/engines/python" python setup.py install
You must call this python
command in the specified
folder.