raw_input causing EOFError after creating exe with py2exe
Asked Answered
G

1

6

After creating an exe from a script with py2exe raw_input() is causing an EOFError.

How can I avoid this?

 File "test.py", line 143, in main
    raw_input("\nPress ENTER to continue ")
EOFError: EOF when reading a line
Gongorism answered 25/11, 2010 at 21:14 Comment(0)
G
4
>>> help(raw_input)
Help on built-in function raw_input in module __builtin__:

raw_input(...)
    raw_input([prompt]) -> string

    Read a string from standard input.  The trailing newline is stripped.
    If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
    On Unix, GNU readline is used if enabled.  The prompt string, if given,
    is printed without a trailing newline before reading.

what's wrong? what do you type on the keyboard?

edit (reported comment up here):

My guess is that you used py2exe with the "windows" argument, meaning that no console is opened - without a console there is no stdin for raw_input to use. You can instead use the "console" argument in your setup.py, and your exe will open a console window allowing raw_input to work

Generatrix answered 25/11, 2010 at 21:19 Comment(3)
I dont get a chance to do/enter anything. I have a raw_input() at the end of the main so that it will pause so I can see data that has been outputted to the stdout. It worked fine before I created and exe... .If there is an alternative to raw_input() for this purpose I could use that. Any ideas?Gongorism
My guess is that you used py2exe with the "windows" argument, meaning that no console is opened - without a console there is no stdin for raw_input to use. You can instead use the "console" argument in your setup.py, and your exe will open a console window allowing raw_input to work------ from mail-archive.com/[email protected]/msg04832.htmlGeneratrix
Yes that was exactly the problem. I was using a rehashed version of a py2exe script that I used for creating an exe for a wxPython gui app, hence the use of the windows argument. ThanksGongorism

© 2022 - 2024 — McMap. All rights reserved.