Python 3: EOF when reading a line (Sublime Text 2 is angry)

Kifsif picture Kifsif · Sep 22, 2012 · Viewed 121.4k times · Source
while True:
    reply = input('Enter text')
    if reply == 'stop': break
    print(reply.upper())

The result was:

Enter text:Traceback (most recent call last):
  File "C:\PythonProjects\5.py", line 2, in <module>
    reply = input('Enter text:')
EOFError: EOF when reading a line
[Finished in 0.2s with exit code 1]

It is only in Sublime Text 2. I tried IDLE, tried command line, everything is perfect. Why should Subleme shout at me?

By the way, maybe you could also explain my what EOF may mean in such situation. Of course, I have read in the documentation, that if EOF is read from input, the appropriate error is raised. I would like to model this situation. Is input only about the keyboard? If yes, what combination of keys should I input to get EOF?

Thank you in advance.

Answer

Raghav Mujumdar picture Raghav Mujumdar · Mar 14, 2013

I had the same problem. The problem with the Sublime Text's default console is that it does not support input.

To solve it, you have to install a package called SublimeREPL. SublimeREPL provides a Python interpreter which accepts input.

There is an article that explains the solution in detail.

GitHub page for SublimeREPL