This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Troubleshooting Error Messages

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 www.python.org/doc or the product documentation from third-party vendors. For example:

p = py.os.path.split(pwd);
py.operator.setitem(p,int32(1),py.str('temp'));
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: https://docs.python.org/2/library/functions.html#tuple.

Python Module Errors

MATLAB reports some Python errors as a MATLAB error loading a module. For more information, see Undefined variable "py" or function "py.command".

If you write your own Python modules or modify the source code from an existing module, test your MATLAB commands by writing the equivalent Python command 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 Explicit Type Conversions.

For example, although MATLAB supports multidimensional arrays, you can only pass vectors of data to Python.

x = py.len([2 3 4; 4 5 6]) 
Error using py.len
Conversion of MATLAB 'double' to Python is only supported for 1-N vectors.

Related Topics

External Websites