os.popen() and (IDLE, PythonWin) ?

M.-A. Lemburg mal at lemburg.com
Mon Nov 1 04:56:26 EST 1999

"M.-A. Lemburg" wrote:
> [os.popen('ver') fails under IDLE and PythonWin, yet works under "normal"
>  Python]

Ok, I found the FAQ entry on this:

7.13. Why doesn't os.popen() work in PythonWin on NT?

The reason that os.popen() doesn't work from within PythonWin is due to a bug in Microsoft's C Runtime
Library (CRT). The CRT assumes you have a Win32 console attached to the process. 

You should use the win32pipe module's popen() instead which doesn't depend on having an attached Win32


 import win32pipe
 f = win32pipe.popen('dir /c c:\\')
 print f.readlines()

Under PythonWin this is no problem (although I wish os.popen would
automatically choose the different approach for me in the above
setup). Yet under IDLE I have a problem: win32 doesn't have to be
installed... is there some other workaround ?

Marc-Andre Lemburg
Y2000:                                                    60 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/

More information about the Python-list mailing list