フィルターのクリア

How to add the path to a local python file to be executed by a Matlab script?

70 ビュー (過去 30 日間)
Jaime Trivino
Jaime Trivino 2021 年 9 月 10 日
回答済み: Emil Skoglund 2023 年 1 月 14 日
Hi,
I want to execute a python function from a Matlab script. How can I add the path to the local python file to be visible to the Matlab script?
Thanks

採用された回答

Jaime Trivino
Jaime Trivino 2021 年 9 月 15 日
I have founf that we can define the path to our own python environment (conda)
pyenv("Version","C:\path to\anaconda3\envs\myenv\python.exe")

その他の回答 (2 件)

Yongjian Feng
Yongjian Feng 2021 年 9 月 12 日
Python uses an env var called PYTHONPATH to point to packages/scripts. So inside matlab, you just need to add the path you want to that env var following this: set env var
  3 件のコメント
Emil Skoglund
Emil Skoglund 2023 年 1 月 14 日
@Jaime Trivino Was your problem related to python environment ?
I am running my scripts just if I keep them in the current path folder, but when I use addpath() it does not work anymore... Was this the problem you had, if so how did you fix it?
Best,
Emil
Emil Skoglund
Emil Skoglund 2023 年 1 月 14 日
Found solution. Posting it.

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


Emil Skoglund
Emil Skoglund 2023 年 1 月 14 日
You need to use this function to add the path of the folder istead of the addpath().
https://se.mathworks.com/matlabcentral/fileexchange/62703-py_addpath-directory-matlab_too

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by