Main Content

Determine if Error is Python or MATLAB Error

Troubleshooting errors when using a MATLAB® external interface is a challenge. Is the error in the Python® application or in your MATLAB code? Common errors include errors reported by Python and errors from attempting to convert Python data to MATLAB and conversely.

Python Error: Python class: message

MATLAB displays an error message in the following format:

Python Error: Python class: message

MATLAB displays message only if there is a Python error message.

This error comes from Python and for information you must refer to your version of Python documentation at or the product documentation from third-party vendors. For example:

p = py.os.path.split(pwd);
Python Error: TypeError: 'tuple' object does not support item assignment

Search for the term “tuple” on the Python documentation site for your version of Python. Tuple is a built-in function described here:

Python Module Errors

MATLAB reports some Python errors as a MATLAB error loading a module. For more information, see Unable to resolve the name py.myfunc.

If you write your own Python modules or modify the source code from an existing module, test your MATLAB statements by writing the equivalent Python statement in your Python interpreter. This workflow is beyond the scope of MATLAB documentation and product support.

Errors Converting Python Data

When the data is compatible, MATLAB automatically converts Python data to MATLAB data. For the list of data types you must explicitly convert, see Explicitly Convert Python Types to MATLAB Types.

Related Topics

External Websites