Main Content


Start MATLAB Engine for Python



eng = matlab.engine.start_matlab() starts a new MATLAB® process, and returns Python® variable eng, which is a MatlabEngine object for communicating with the MATLAB process.

If MATLAB cannot be started, the engine raises an EngineError exception.


eng = matlab.engine.start_matlab(option) uses startup options specified by option.

For example, call matlab.engine.start_matlab('-desktop') to start the MATLAB desktop from Python.


eng = matlab.engine.start_matlab(background) starts MATLAB asynchronously if background is True.

eng = matlab.engine.start_matlab(async) starts MATLAB asynchronously if async is True. Not recommended. Use the background argument instead. Do not use for Python Version 3.7. For more information, see Compatibility Considerations.


eng = matlab.engine.start_matlab(___) can include any of the input arguments in previous syntaxes.


collapse all

Start an engine and a new MATLAB process from the Python command line.

import matlab.engine
eng = matlab.engine.start_matlab()

Start a different MATLAB process from each engine.

import matlab.engine
eng1 = matlab.engine.start_matlab()
eng2 = matlab.engine.start_matlab()

Start an engine with the MATLAB desktop.

import matlab.engine
eng = matlab.engine.start_matlab("-desktop")

You also can start the desktop after you start the engine.

import matlab.engine
eng = matlab.engine.start_matlab()


You can call MATLAB functions from both the desktop and Python.

Start the engine with background=True. While MATLAB starts, you can enter commands at the Python command line.

import matlab.engine
future = matlab.engine.start_matlab(background=True)
eng = future.result()

Input Arguments

collapse all

Startup options for the MATLAB process, specified as a string. You can specify multiple startup options. The engine supports all MATLAB startup options, except for the options listed in Limitations. For a list of options, see the platform-specific command matlab (Windows), matlab (macOS), or matlab (Linux).

To start MATLAB with the desktop, use the '-desktop' option.

Example: matlab.engine.start_matlab('-desktop -r "format short"') starts the desktop from Python. The engine passes '-r "format short"' to MATLAB.

Start MATLAB synchronously or asynchronously, specified as a logical keyword argument. background is an alias for async.

Example: matlab.engine.start_matlab(background=True)

Start MATLAB synchronously or asynchronously, specified as a logical keyword argument.

Output Arguments

collapse all

Python variable for communicating with MATLAB, returned as a MatlabEngine object if async or background is set to False or a FutureResult object if async or background is set to True.

Each time you call matlab.engine.start_matlab, it starts a new MATLAB process.


The engine does not support these MATLAB startup options:

  • -h

  • -help

  • -?

  • -n

  • -e

  • -softwareopengl

  • -logfile

Compatibility Considerations

expand all

Introduced in R2014b