ExecutionMode set to pyenv in matlab batch mode is not persistent
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
According to pyenv documentation (from https://mathworks.com/help/matlab/ref/pyenv.html):
> Use pyenv to change the default version or execution mode of the Python® interpreter. These changes are persistent across different MATLAB® sessions.
However, in both R2022a on Windows and R2022b on Linux I am experiencing that the changes done by pyenv are not persistent when they are done in batch mode.
In particular, the following happens. If I just call, it gives the value that I set in the MATLAB gui:
matlab -batch "pyenv().ExecutionMode"
ans =
ExecutionMode enumeration
OutOfProcess
However, if I try to set the value in batch mode, it does not seem that the changes are saved. It is trivial to see this by executing in sequence:
matlab -batch "pyenv().ExecutionMode"
matlab -batch "pyenv(ExecutionMode='InProcess')"
matlab -batch "pyenv().ExecutionMode"
matlab -batch "pyenv(ExecutionMode='OutOfProcess')"
matlab -batch "pyenv().ExecutionMode"
I would expect that the first call returns the value of ExecutionMode already set, while the third and the fifth command return `OutOfProcess` and `InProcess` . Instead, this does not happens, and the value set is always the one set originally:
C:\Users\STraversaro>matlab -batch "pyenv().ExecutionMode"
ans =
ExecutionMode enumeration
OutOfProcess
C:\Users\STraversaro>matlab -batch "pyenv(ExecutionMode='InProcess')"
ans =
PythonEnvironment with properties:
Version: ""
Executable: ""
Library: ""
Home: ""
Status: NotLoaded
ExecutionMode: InProcess
C:\Users\STraversaro>matlab -batch "pyenv().ExecutionMode"
ans =
ExecutionMode enumeration
OutOfProcess
C:\Users\STraversaro>matlab -batch "pyenv(ExecutionMode='OutOfProcess')"
ans =
PythonEnvironment with properties:
Version: ""
Executable: ""
Library: ""
Home: ""
Status: NotLoaded
ExecutionMode: OutOfProcess
C:\Users\STraversaro>matlab -batch "pyenv().ExecutionMode"
ans =
ExecutionMode enumeration
OutOfProcess
Is this the expected behaviour? There is any way of settng this value in a persistent way in batch mode? Thanks a lot in advance!
0 comentarios
Respuestas (2)
Mann Baidi
el 25 de Ag. de 2023
Hi Silvio,
I understand that you are facing issue in changing the pyenv.ExecutionMode() using the batch command. I suggest you try changing the variable using the MATLAB command window.
You can take the reference from the following link.
Hope this helps!
1 comentario
Mann Baidi
el 31 de Ag. de 2023
Hi,
I think you can directly change the ExecutionMode using script also, You can just type:
pyenv()
Then change the Execution Mode
pyenv("ExecutionMode","OutOfProcess")
The pyenv.ExecutionMode would then be:
pyenv().ExecutionMode
0 comentarios
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!