使用py2exe创建exe后,raw_input导致EOFError

vol*_*ing 6 python py2exe eoferror

从脚本创建exe后py2exe raw_input()导致EOFError.

我怎么能避免这个?

 File "test.py", line 143, in main
    raw_input("\nPress ENTER to continue ")
EOFError: EOF when reading a line
Run Code Online (Sandbox Code Playgroud)

Ant*_*Ant 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.
Run Code Online (Sandbox Code Playgroud)

怎么了?你在键盘上输入什么?

编辑(此处报告评论):

我的猜测是您使用了 py2exe 和“windows”参数,这意味着没有打开控制台 - 没有控制台就没有可供 raw_input 使用的标准输入。您可以在 setup.py 中使用“console”参数,并且您的 exe 将打开一个控制台窗口,允许 raw_input 工作