Change default version of Python interpreter
[version, executable, isloaded] = pyversion
___ = pyversion version
___ = pyversion executable
pyversion displays details about the current Python® version.
___ = pyversion changes the
default Python version on Microsoft®
Windows® platforms. You can request any of the outputs from previous
syntaxes. The setting is persistent across MATLAB® sessions.
You cannot change the version after MATLAB loads Python. To change the version if Python is loaded already, restart MATLAB, and then call
___ = pyversion specifies the
full path to the Python executable. You can use this syntax on any platform or for
repackaged CPython implementation downloads.
version: '2.7' executable: 'C:\Python27\python.exe' library: 'C:\windows\system32\python27.dll' home: 'C:\Python27' isloaded: 0
[v, e, isloaded] = pyversion; if isloaded disp('To change the Python version, restart MATLAB, then call pyversion.') else pyversion 2.7 end
version— Python version
Python version number, specified as a string or character vector. The version must contain the major and minor version numbers separated by a period. (Windows platform only)
pyversion looks for the version in the Windows registry. If you download the Python application from
the installation automatically adds the version to the registry. If you
download the application from a different source, you must either add it to
the registry or use the
pyversion(executable) syntax to
change the version.
executable— Name of existing Python executable file
Name of an existing Python executable file, specified as a string or character vector. This argument must contain the name of the Python executable file, and it can contain the full path.
version— Python version
Python version number, returned as a character vector.
executable— Name of Python executable file
Name of Python executable file, returned as a character vector.
isloaded— Version loaded indicator
Version loaded indicator specifying if this version is loaded, returned as
logical. MATLAB loads Python when you type a
If MATLAB cannot load Python,
MATLAB displays Undefined variable "py" or function "py.command" when you type a
Do not use
pyversion to set the version in a MATLAB function containing Python commands. Before MATLAB executes the
pyversion function, it loads the
Python interpreter when it processes a Python command in the function.