Reputation: 33
Whenever I try to build code in Sublime Text 2 (Python 2.7) in which there is either input() or raw_input(), I get this error:
EOFError: EOF when reading a line [Finished in 0.1s with exit code 1]
I've found some tutorials that said it's a problem about ST not locating Python, so I edited the file that should have fixed it, to no avail. I still get the same error.
What is the problem here, and how can this be fixed?
Upvotes: 0
Views: 235
Reputation: 102842
It's not an issue with ST not locating Python, rather, it's the fact that ST does not support interactivity when building programs - input()
/raw_input()
in Python, gets
in Ruby, scanf
and associates in C/C++, Scanner
in Java, etc. For compiled languages, the workaround is to run your program through the shell, which handles input. This can also be done with interpreted languages like Python, Ruby, Perl, etc., but for many people their preferred solution is to use SublimeREPL
, available via Package Control. This essentially runs an interactive Python shell within Sublime, either the standard Python shell or IPython, which I prefer for a number of reasons.
SublimeREPL comes with a series of commands for taking lines, blocks, selections, or entire code files and passing them through the REPL (it has to be started manually first), which then takes care of handling input and output. Alternatively, if you're just testing smaller snippets of code, you can just enter and run it within SublimeREPL itself - I find myself doing this extremely often, it's incredibly helpful.
Upvotes: 0