Main Content

pyversion

(Not recommended) Change default version of Python interpreter

pyversion is not recommended. Use pyenv instead.

Description

pyversion displays details about the current Python® version.

[version, executable, isloaded] = pyversion returns Python version information.

___ = pyversion version 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.

___ = pyversion executable specifies the full path to the Python executable. You can use this syntax on any platform or for repackaged CPython implementation downloads.

Input Arguments

collapse all

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)

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.

Output Arguments

collapse all

Python version number, returned as a character vector.

Name of Python executable file, returned as a character vector.

Version loaded indicator specifying if this version is loaded, returned as logical. MATLAB loads Python when you type a py. command.

If MATLAB cannot load Python, isloaded is 0 and MATLAB displays Unable to resolve the name py.myfunc when you type py.myfunc for a command you want to execute.

Version History

Introduced in R2014b

collapse all

R2019b: pyversion is not recommended

pyversion is not recommended. Use pyenv instead. There are no plans to remove pyversion at this time.

To execute Python functions out-of-process, MATLAB provides a new function, pyenv. This function configures Python environment settings, including the version. Even if you do not use the out-of-process feature, MathWorks recommends using pyenv for managing all variables. For more information, see Out-of-Process Execution of Python Functionality.

See Also