Calling python script with 'system'

20 ビュー (過去 30 日間)
adajaga
adajaga 2019 年 2 月 13 日
回答済み: Saumya Goel 2019 年 2 月 18 日
I am trying to run a python script from within MATLAB just using the system command, i.e.
[~,result] = system(['python myscript.py someInputFile.out'])
This script relys on a library (openAi gym). When I try to run this python script I get:
import gym
ImportError: No module named gym
The script works fine when I call it from the command line. My python version is the same as is used in my shell. I'm not an expert in python, but I know MATLAB launches works inside its own shell, maybe there is there something I need to do to ensure that the 'gym' module is in my python path?
I know there are more elegant ways now to integrate MATLAB and python, but I'm under a bit of time pressure and was hoping for a quick fix.
Thanks!

回答 (1 件)

Saumya Goel
Saumya Goel 2019 年 2 月 18 日
You can refer to below MATLAB documentation in order to execute user defined python script from MATLAB:
Additionally, you can refer to the Getting Started page from MATLAB documentation to understand different ways of executing Python scripts/commands from MATLAB.

カテゴリ

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