Effacer les filtres
Effacer les filtres

2014b python from Matlab stdout oddity

2 vues (au cours des 30 derniers jours)
Chris Barnhart
Chris Barnhart le 20 Jan 2015
Modifié(e) : Chris le 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.

Réponse acceptée

Chris Barnhart
Chris Barnhart le 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

Plus de réponses (0)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by