python environment mysteriously loads by itself?

12 ビュー (過去 30 日間)
dleal
dleal 2022 年 6 月 3 日
回答済み: Siraj 2023 年 9 月 25 日
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 件のコメント
dleal
dleal 2022 年 6 月 4 日
no. I called it initPython.m
dleal
dleal 2022 年 6 月 4 日
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

サインインしてコメントする。

回答 (1 件)

Siraj
Siraj 2023 年 9 月 25 日
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.

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by