Main Content

Limitations to Python Support

The Python® interface in MATLAB® enables you to access Python libraries, execute Python statements, and pass data between MATLAB and Python. However, the Python interface does not currently support the following functionality.

Functionality Not Supported in MATLAB

Closing the Python interpreter while running MATLAB with in-process execution mode

Saving (serializing) Python objects into a MAT file

Passing Python objects to process workers in a parallel pool

Passing Python objects or keyword arguments created by pyargs as key arguments to the MATLAB dictionary function or as input to the keyMatch function

Calling Python help (py.help) without input arguments

Accessing static properties of a Python class

Using the MATLAB isa function to recognize virtual inheritance

Inheriting a MATLAB class from a Python class

Customizing (dynamic) attribute access

Nesting Python classes

Using Python modules (such as the multiprocessing module) to start MATLAB

Using Python modules (such as tkinter) to read the command-line arguments passed to a Python script

Dynamically generating Python classes

Dynamically attaching new object attributes. Instead, use the Python py.setattr function.

Using class names or other identifiers that start with an underscore (_) character. Instead, use the Python py.getattr and py.setattr functions.

Using Python modules generated by MATLAB Compiler SDK™

Using Python code that uses Cocoa (AppKit) for interfaces on macOS platforms

Passing variables that exceed 2 GB between Python and MATLAB when calling a Python function out-of-process. This limit applies to the data plus supporting information passed between the processes.

Modifying Python classes defined using pyrun or pyrunfile. For more information, see Directly Call Python Functionality from MATLAB

Converting types based on Python type hints when using pyrun, pyrunfile, or the Run Python Code task, where you provide native Python code as input

Unsupported MATLAB Types

These MATLAB types are not supported in Python:

  • Sparse arrays

  • Nonscalar struct arrays

  • categorical

  • containers.Map

  • MATLAB objects

  • matlab.metadata.Class (py.class)

See Also

Topics