pythonmatlab

Getting an Error Message in MATLAB using pyenv


When using following command:

pyenv(Version="C:\Programm Files\Python37\python.exe")

I get this error message:

Error: Incorrect use of '=' operator. To assign a value to a vatiable, use '='. To compare values for equality, use '=='.

Do you have any idea what the problem is?

I tried

!matlab &
exit

I am using MATLAB 2019b


Solution

  • More often than not, the MATLAB documentation will tell you everything you need to know. In your case, if you read the documentation for pyenv, under the section "Input Arguments" it says:

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    The syntax you are using was introduced in MATLAB R2021a, so doesn't work in your version of MATLAB.

    You need to do

    pyenv('Version', "C:\Programm Files\Python37\python.exe")