pyversion can't be set in startup file on Linux
8 ビュー (過去 30 日間)
古いコメントを表示
I am running R2017b on Ubuntu 16.04 LTS. I would like to make sure that while working on a particular project I always have python loaded. So I tried to put a python call in the startup.m file (or use the pyversion command) to make sure that python was loaded.
But Matlab errors and can't find the "py" variable, and subsequently can't finish the startup file. Yet, if I run the startup file just after Matlab is opened, it works just fine.
How can I make sure that python is loaded in my startup file? Or does Matlab only load its python interface after the call to startup.m?
0 件のコメント
回答 (1 件)
Karan Singh
2025 年 2 月 3 日 5:53
Hi @aepound, I think your intuition makes sense, Python is likely initialized after the startup.m script runs, which explains why it executes afterward. How about adding a "Timer" delay for Python initialization? This could help ensure that Python starts only after MATLAB has fully initialized.
timerObj = timer(...
'StartDelay', 1, ... // time based on your scenario
'TimerFcn', @(~,~) initializePythonFile(), ...
'ExecutionMode', 'singleShot' ...
);
start(timerObj);
Can you add the same in your startup.m file and check if this might be able to work.
Karan
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!