Filter löschen
Filter löschen

2014b python from Matlab stdout oddity

2 Ansichten (letzte 30 Tage)
Chris Barnhart
Chris Barnhart am 20 Jan. 2015
Bearbeitet: Chris am 21 Jan. 2015
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.

Akzeptierte Antwort

Chris Barnhart
Chris Barnhart am 21 Jan. 2015
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

Weitere Antworten (0)

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by