Why can't I run my python script from Matlab?
6 ビュー (過去 30 日間)
古いコメントを表示
Hi
I am trying to use this line
py.intervals.py();
Where intervals is a python script. I get the error
>> py.intervals.py()
Undefined variable "py" or class "py.intervals.py".
I am using R2018b. Do I need to purchase a Python Libraries API?
0 件のコメント
回答 (3 件)
Prathamesh Degwekar
2019 年 5 月 21 日
Hi,
I see two possible corrections you could try. Firstly try calling the python module itself instead of the file name (like "py.mymod.search(N)" instead of "py.mymod.py").
Secondly, maybe your file isn't in the python search path. If it isn't, try adding your folder to the python sys path using:
if count(py.sys.path,'') == 0
insert(py.sys.path,int32(0),'');
end
0 件のコメント
Rafael Rebouças
2021 年 1 月 19 日
編集済み: Rafael Rebouças
2021 年 1 月 19 日
My solution:
% Simple way to load your library
copyfile(my_library_file_path, pwd, 'f');
% It's necessary to load library
py.my_library.any_method_or_function();
delete 'my_library.py';
Now, your Python library is loaded to use in any directory.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Python Package Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!