raw_input causing EOFError after creating exe with py2exe

两盒软妹~` 提交于 2019-11-30 05:02:48

问题


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

回答1:


>>> 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



来源:https://stackoverflow.com/questions/4280889/raw-input-causing-eoferror-after-creating-exe-with-py2exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!