A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/325109.html below:

stdin and py2exe

stdin and py2exeThomas Heller theller at python.net
Wed Sep 14 13:38:58 EDT 2005
"Mike Tammerman" <mtammerman at gmail.com> writes:

> 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

Can it be that you're building a windows exe of subprogram.py? I get the
error you describe when I do that,  for console programs it works -
both in the Python script and in the py2exe'd version.

This is, afaik, standard windows behaviour: GUI programs start with
stdin, stdout and stderr closed.

Thomas

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4