stdin and py2exe

Mike Tammerman mtammerman at gmail.com
Wed Sep 14 13:27:57 EDT 2005


Hi,

I want create a subprocess using Popen and pipe some input to it.
Although everything works perfectly while executing python in, it
doesn't work if I try with executables made by py2exe.

I think, stdin is invalidated if the program becomes an executable.
Because I get a "Bad file descriptor" exception in subprogram.py. I
will be more than apreciated, if any suggestions occur.

Thanks,
Mike

== main.py ==
from subprocess import *

pInput = Popen('python subprogram.py', stdin=PIPE, shell=True).stdin
# pInput = Popen('subprogram.exe', stdin=PIPE, shell=True).stdin #
doesn't work

pInput.write('Data')
pInput.close()


== subprogram.py ==
import sys

input = sys.stdin.read()  # Throws a bad descriptor exception.
print input




More information about the Python-list mailing list