python environment mysteriously loads by itself?

13 visualizzazioni (ultimi 30 giorni)
dleal
dleal il 3 Giu 2022
Risposto: Siraj il 25 Set 2023
The title of this post summarizes the issue. I am slighty confused why Python loads without my explicit permission.
I am working on a MATLAB project where startup file contains a line that loads Python using pyenv.
If I wait a few minutes between opening MATLAB and starting the project, I get the "Python is loaded" error message, even though I haven't yet loaded it:
Warning: Error using pyenv
Python is loaded. The environment cannot be changed in this MATLAB session. To change the environment, restart MATLAB, and then call 'pyenv'.
I understand my question might be a bit vague and I would be glad to provide more details as needed... I'm not quite sure where to go from here
  5 Commenti
dleal
dleal il 4 Giu 2022
no. I called it initPython.m
dleal
dleal il 4 Giu 2022
I attached a sample file, it wont run, but at least you can see how I am invoking Python... the only thing I can think might cause an issue is that I am loading an Anaconda environment and maybe MATLAB loads it by itself

Accedi per commentare.

Risposte (1)

Siraj
Siraj il 25 Set 2023
Hi!
It seems that you have a query regarding why Python is loading without your explicit permission. You mentioned working on a project that involves an "initPython3.m" startup file. This file, which is a .m script, runs automatically when you open a saved project. However, even if you are not actively starting the project, you are still encountering the "Python is loaded" error.
The reason for this behaviour is that starting from R2014b and subsequent releases, MATLAB has a default preference where the last working directory from the previous session is set as the Startup Folder. This means that when you double-click the MATLAB icon on your Windows desktop or in the Start menu, it will open in the last working directory.
If you had a project open when you closed MATLAB, the next time you open MATLAB, it will automatically open that project and execute the "initPython3.m" startup file, even if you didn't explicitly open the project. You can find more information about the "MATLAB Startup Folder" in the following link.
To understand the possible causes of the "Python is loaded" error and explore potential workarounds, you can refer to the following link.
Hope this helps.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by