Cannot run Python script on Windows with output redirected??
Posted
by Wai Yip Tung
on Stack Overflow
See other posts from Stack Overflow
or by Wai Yip Tung
Published on 2010-06-10T21:55:19Z
Indexed on
2010/06/10
22:02 UTC
Read the original article
Hit count: 294
This is running on Windows 7 (64 bit), Python 2.6 with Win32 Extensions for Python.
I have a simple script that just print "hello world". I can launch it with python hello.py
. In this case I can redirect the output to a file. But if I run it by just typing hello.py
on the command line and redirect the output, I get an exception.
C:> python hello.py
hello world
C:> python hello.py >output
C:> type output
hello world
C:> hello.py
hello world
C:> hello.py >output
close failed in file object destructor:
Error in sys.excepthook:
Original exception was:
I think I first get this error after upgrading to Windows 7. I remember it should work in XP. I have seen people talking about this bug python-Bugs-1012692 | Can't pipe input to a python program. But that was long time ago. And it does not mention any solution.
Have anyone experienced this? Anyone can help?
© Stack Overflow or respective owner