フィルターのクリア

A simple python script testmodel.py which is written response=raw_input(), but It can not be called successfully in Matlab

2 ビュー (過去 30 日間)
One simple test python script:
testmodel.py:
response=raw_input()
Then in Matlab i want to call this script, I just type py.testmodel.response to get the value of response.But It finally goes wrong and returns the Error Undefined variable 'py' or class py.testmodel.response.
So I want to know how to correct the script. Is there any method can correct it? Thank you !!!!
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 10 月 9 日
Which MATLAB version are you using? And which operating system?
Jianzhou Liu
Jianzhou Liu 2016 年 10 月 9 日
I have matlab2015a and python2.7 in MacOS and matlab2015b and python2.7 in Ubuntu

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

回答 (1 件)

Robert Snoeberger
Robert Snoeberger 2016 年 10 月 11 日
There are two parts to my answer:
1) When you see the error "Undefined variable 'py' or class 'py.testmodel.response'", call the Python function import_module() to get a more detailed error message.
>> py.importlib.import_module('testmodel')
2) I believe the error will say, "EOFError: EOF when reading a line." py.input and py.raw_input (version 2.7) are listed in the limitations to Python support .
I see the following when I try to use raw_import:
>> response = py.raw_input
Python Error: EOFError: EOF when reading a line
>>

カテゴリ

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