1

I'm using Sublime Text 2. When building this code:

first = input()
print (first)

I'm getting this error:

Traceback (most recent call last):
  File "C:\Users\user\Desktop\21314", line 1, in <module>
    first = input()
EOFError: EOF when reading a line
[Finished in 0.2s]

Why?

vaultah
  • 44,105
  • 12
  • 114
  • 143
BenFire
  • 749
  • 1
  • 5
  • 7

2 Answers2

1

There is another solution that still allows you to use Sublime's build systems, in case SublimeREPL doesn't exactly fit into your workflow. Create a new file with the following contents:

{
    "cmd": ["start", "cmd", "/k", "c:/python33/python.exe", "$file"],
    "selector": "source.python",
    "shell": true,
    "working_dir": "$file_dir"
}

and save it as Packages/User/Python_cmd.sublime-build where Packages is the folder opened when selecting Preferences -> Browse Packages... - it should be %APPDATA%/Sublime Text 2/Packages for you.

Next, go to Tools -> Build System and select Python_cmd down at the bottom, then switch to your .py file and hit CtrlB to build. A new command line window will open, allowing you to input values to your heart's content. When the program is done, the window will remain open, allowing you to examine output, tracebacks, etc. Just close the window to return to Sublime.

I highly recommend SublimeREPL for interactive development, and running small bits of code, but there are definitely times when you want to interact with your program in a command-line environment. This build system allows you to do that, without switching over to an open command window and manually running python myprogram.py every time you want to build.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
0

Run the script from the terminal or command line.

Sublime Text 2 itself doesn't allow you to input anything during the build, so the EOFError is raised because your input is empty.

Possible workaround is described here: Sublime Text 2 console input

The complete solution is to install SublimeREPL (a package for Sublime Text). Learn how to from here: Python input EOFError in Sublime Text 2

Community
  • 1
  • 1
vaultah
  • 44,105
  • 12
  • 114
  • 143