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 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 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
- Limitations to Python Support
- Unable to resolve the name py.myfunc
- How can I debug Python code using MATLAB's Python Interface and Visual Studio Code