フィルターのクリア

2014b python from Matlab stdout oddity

2 ビュー (過去 30 日間)
Chris Barnhart
Chris Barnhart 2015 年 1 月 20 日
編集済み: Chris 2015 年 1 月 21 日
It appears that when running a python script from within matlab that the python stdout is redirected in some odd way. It does not appear in the matlab session from which the python commands are executed, but instead are redirected in an undefined manner.
For example, I see nothing when I run:
>>py.print('123')
I believe the output is going to a parent process. To see this - start a 2014b session, then within this session start a new matlab session (eg child matlab). Eg.
system('matlab')
Now in the child session, create some python output (enough to cause a flush). eg.
py.print(py.range(int16(1),int16(1000) ))
For me, the output appears in the parent matlab session.
This little hack solves 2 problems for me, first there is no reload() to cause matlab to see changes to python scripts. Reloading matlab is required. 2nd, until now, I've found no way to see python stdout, or stderr.

採用された回答

Chris Barnhart
Chris Barnhart 2015 年 1 月 21 日
Mathworks ask me to re-install Matlab which fixed this and another problem (no PyException). However, the root causes are likely related to path editing.
I found a file redirectstdout.m located within - C:\Program Files\MATLAB\R2014b\toolbox\matlab\external\interfaces\python\+python\+internal
And PyExceptions lives nearby by: C:\Program Files\MATLAB\R2014b\toolbox\matlab\external\interfaces\python\+matlab\+exception

その他の回答 (0 件)

カテゴリ

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