Azzera filtri
Azzera filtri

2014b python from Matlab stdout oddity

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Chris Barnhart
Chris Barnhart il 21 Gen 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

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by