使用 py2exe 创建 exe 后,raw_input 导致 EOFError [英] raw_input causing EOFError after creating exe with py2exe
问题描述
使用 py2exe
从脚本创建 exe 后,raw_input()
导致 EOFError.
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
推荐答案
>>> 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):
我的猜测是您使用了带有windows"参数的 py2exe,这意味着没有打开控制台——没有控制台,就没有用于 raw_input 的标准输入.您可以改为在 setup.py 中使用console"参数,您的 exe 将打开一个控制台窗口,允许 raw_input 工作
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
这篇关于使用 py2exe 创建 exe 后,raw_input 导致 EOFError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!