Reputation: 43
I have tried using subprocess .Popen in Python IDLE, in both versions 2.7 and 3.2 and the code didn't work!!!
Thank you.
Upvotes: 1
Views: 1433
Reputation: 91017
I suspect that IDLE redirects Python's stdout
so that print
ing happens in the window, but it doesn't redirect file descriptor 1, so that any subprocess happily prints to that file descriptor.
Try to start IDLE from the command line, run these lines and see if their output is printed to the terminal where IDLE is called from.
Solutions:
python
interpreter called from the command line.Redirect the output of your processes to a pipe, read this pipe and output it. Such as:
sp = subprocess.Popen(['ls'], stdout=subprocess.PIPE)
for i in sp.stdout: print i
sp.wait()
Upvotes: 2