System and Configuration Requirements

Python Version Support

To call Python® modules in MATLAB®, you must have a supported version of the reference implementation (CPython) installed on your system. MATLAB supports the following versions:

  • Version 2.7

  • Version 3.5

  • Version 3.6

  • Version 3.7

To determine if your system has a supported version, use the pyversion function. The value set by pyversion is persistent across MATLAB sessions.

You cannot switch between versions of Python in a single MATLAB session. MATLAB automatically selects and loads a Python version when you type a Python command, such as:

py.funcname

If you want to change versions, restart MATLAB and then run pyversion with the new version information.

Set Python Version on Windows Platform

On Windows® platforms, use either:

pyversion version

or

pyversion executable

Note

If you downloaded a Python interpreter, but did not register it in the Windows registry, use:

pyversion executable

Set Python Version on Mac and Linux Platforms

To set the version, type:

pyversion executable

where executable is the full path to the Python executable file.

Download 64-Bit Version of Python on Windows Platforms

The architecture of Python must match the architecture of MATLAB. On the Python download website, downloads for Microsoft® Windows platforms are 32-bit versions by default. To download the 64-bit version, choose options with the name "Windows x86-64 MSI installer”.

Requirements for Building Python Executable

On Linux® and Mac systems, if you build the Python executable, configure the build with the --enable-shared option.

See Also

External Websites