python
io_error
official
true
EOFError
ID: python/eoferror
80%Fix Rate
95%Confidence
0Evidence
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
The input() function hit an end-of-file condition (EOF) without reading any data. Common in piped input, redirected stdin, or closed file descriptors.
genericOfficial Documentation
https://docs.python.org/3/library/exceptions.htmlWorkarounds
-
90% success Check sys.stdin.isatty() before calling input()
If not a TTY, read from sys.stdin directly or use command-line arguments
-
90% success Use argparse or click for non-interactive input
Accept data via CLI arguments instead of interactive prompts
Dead Ends
Common approaches that don't work:
-
Retrying input() in a loop
80% fail
If stdin is closed, it will keep raising EOFError indefinitely