Python: EOFError: EOF when reading a line

31,027

Solution 1

The issue here is that Sublime text 2's console doesn't support input.

To fix this issue, you can install a package called SublimeREPL. SublimeREPL provides a Python interpreter that takes in input.

And as for compileronline.com, you need to provide input in the "STDIN Input" field on the lower right of the website.

Solution 2

try:
    value = raw_input()
    do_stuff(value) # next line was found 
except (EOFError):
   break #end of file reached

This seems to be proper usage of raw_input when dealing with the end of the stream of input from piped input. Refer this post

Share:
31,027
Héctor Salazar
Author by

Héctor Salazar

Updated on February 05, 2020

Comments

  • Héctor Salazar
    Héctor Salazar over 4 years

    This may be repeated, but none of the existing answers solved my problem.

    So, I'm using Python 2.7, and I get this error (title) whenever I try this:

    number = int(raw_input('Number : '))
    

    I tried this in Sublime Text 2, compileronline.com and in codecademy; it fails in the first 2 of this sites. It works on codecademy and in the terminal compiler, but I can't understand exactly why it is failing.