フィルターのクリア

How to call python Script in specified environment in Matlab?

10 ビュー (過去 30 日間)
Shohei Uchigasaki
Shohei Uchigasaki 2021 年 11 月 5 日
コメント済み: Shohei Uchigasaki 2021 年 11 月 8 日
I want to call a python script in matlab script.
I want to call a python script in miniconda 'test' environment, but I can't do this.
This is because it happens version missmatch like this.:
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.7"
Executable: "/home/usrs/xxxxxx/miniconda3/envs/test/bin/python"
Library: "/home/usrs/xxxxxx/miniconda3/envs/test/lib/libpython3.7m.so"
Home: "/home/usrs/xxxxxx/miniconda3/envs/test"
Status: NotLoaded
ExecutionMode: OutOfProcess
>> !python
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/usrs/xxxxxx/miniconda3/lib/python38.zip',
'/home/usrs/xxxxxx/miniconda3/lib/python3.8',
'/home/usrs/xxxxxx/miniconda3/lib/python3.8/lib-dynload',
'/home/usrs/xxxxxx/miniconda3/lib/python3.8/site-packages']
I want to call python script like this:
>> !python test.py
I want to use python 3.7 and 'test' environment, but matlab has called python 3.8.3 and 'base' environment.
What should I do for this problem?
Thanks.

採用された回答

Konrad
Konrad 2021 年 11 月 5 日
Hi,
please see this answer by Walter. I think pyenv() affects only python calls using the py.-prefix. But calling python via system() (or !) uses the python interpreter registered in the systems PATH variable.
Best, Konrad
  1 件のコメント
Shohei Uchigasaki
Shohei Uchigasaki 2021 年 11 月 8 日
I have solved my question by this llink!! Thank you so much!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by