This is not likely to help Apollo (besides, question is 4 years old), but this might help someone like myself.
I had this same issue and without hitting a single key, the same code would terminate immediately into EOFError. In my case, culprit was another script executed earlier in the same terminal, which had set stdin into non-blocking mode.
Should the cause be the same, this should help:
flag = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, flag & ~os.O_NONBLOCK)
I identified the offending Python script and made the correction. Other scripts with input() now work just fine after it.
Edit (plus couple of typos above):
This should let you see if STDIN is non-blocking mode:
import os
import sys
import fcntl
flag = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
print(
"STDIN is in {} mode"
.format(
("blocking", "non-blocking")[
int(flag & os.O_NONBLOCK == os.O_NONBLOCK)
]
)
)
test.pyvs what you copied and pasted? Because the Traceback as well as the output shows a completely differentinputcommand. I cannot replicate this error on my system. (I getKeyboardInterruptas expected.)