Main Content

La traducción de esta página aún no se ha actualizado a la versión más reciente. Haga clic aquí para ver la última versión en inglés.

Llamar a Python desde MATLAB

Llame directamente a las funciones de Python® desde MATLAB®

Puede acceder a las bibliotecas de Python directamente desde MATLAB agregando el prefijo py. al nombre Python. Consulte Acceder a módulos de Python desde MATLAB: introducción. Por ejemplo:

py.list({'This','is a','list'})      % Call built-in function list
py.textwrap.wrap('This is a string') % Call wrap function in module textwrap
Puede ejecutar instrucciones de Python en el intérprete de Python directamente desde MATLAB usando las funciones pyrun o pyrunfile. Por ejemplo:
pyrun("l = ['A','new','list']")  % Call list in Python interpreter
Para obtener más información, consulte Llamar directamente a funcionalidades de Python desde MATLAB.

Si en su lugar desea llamar a las funciones de MATLAB desde las aplicaciones de Python, consulte Llamar a MATLAB desde Python para obtener más información.

Funciones

expandir todo

pyenvChange default environment of Python interpreter (desde R2019b)
PythonEnvironmentPython environment information (desde R2019b)
pyrunRun Python statements from MATLAB (desde R2021b)
pyrunfileRun Python script file from MATLAB (desde R2021b)
pyargsCreate keyword arguments for Python function
matlab.exception.PyExceptionCapture error information for Python exception

Temas

Usar bibliotecas de Python en MATLAB

Ejecutar código de Python desde MATLAB

Paso de datos

Solución de problemas

Determine if Error is Python or MATLAB Error

Tips to determine if an error originates in Python or MATLAB code.

Limitations to Python Support

Python features not supported in MATLAB.

Handle Python Exceptions

MATLAB catches exceptions thrown by Python and converts them into a matlab.exception.PyException object.

Troubleshooting Matrix and Numeric Argument Errors

Error might be caused by input array with more than one non-singleton dimension.

Error Converting Elements of list or tuple

How to use string and numeric converters for list and tuple types.