banner ad

Python input EOFError in Sublime Text 2

| January 24, 2013 | 4 Comments
1 Flares 1 Flares ×

I use sublime text 2, but return an EOFError when use function input or raw_input. The code

#!/bin/user/env python

f = input('Enter a number:')
print f 

when I use the ctrl+b to build, get the error:
Enter a number:Traceback (most recent call last):
File “C:\Users\bing\Desktop\test.py”, line 3, in
f = input(‘Enter a number:’)
EOFError: EOF when reading a line
[Finished in 0.2s with exit code 1]

Because the sublime text 2 don’t support input. When using SublimeREPL can solve this problem.

Install Package Control
Press Ctrl + ` to bring up the console
Paste the following code in command line and press Enter:

import urllib2, os; pf = ‘Package Control.sublime-package’; ipp = sublime.installed_packages_path (); os.makedirs (ipp) if not os.path.exists (ipp) else None; open (os.path.join (ipp, pf), ‘wb’). write (urllib2.urlopen (‘http://sublime.wbond.net/’ + pf.replace (”, ‘% 20’)). read ())

Restart Sublime Text 2.
If you see in the Perferences-> package control ,that is  successful.

Use ctrl+shift+p, input install and install package.

Tools->SublimeREPL->python->run python

sublime

 

 

that’s all.

Download PDF
1 Flares Twitter 1 Facebook 0 Google+ 0 Pin It Share 0 LinkedIn 0 Reddit 0 StumbleUpon 0 1 Flares ×

Tags: , ,

Category: Sublime Text

About the Author ()

My name is John Link.I am 26 years old. My major is Computer science and technology. I am a junior programmer with Python.

Comments (4)

Trackback URL | Comments RSS Feed

  1. Leo says:

    This code gives me an IndentationError: unexpected indent. I double checked the spaces, and made sure 4 spaces where indented in said line.

    code:
    weight = raw_input(“How many pounds does your suitcase weigh? “)
    if weight > 50:
    print(“There is a $25 charge for luggage that heavy.”)
    print(“Thank you for your business.”)

    output:
    How many pounds does your suitcase weigh? >>> File “”, line 1
    print(“There is a $25 charge for luggage that heavy.”)
    ^
    IndentationError: unexpected indent

    • admin says:

      Check if you mixed tabs and spaces, that is a frequent source of indentation errors

    • PuTTy says:

      weight = raw_input(“How many pounds does your suitcase weigh? “)
      if weight > 50:
      print(“There is a $25 charge for luggage that heavy.”)
      print(“Thank you for your business.”)

      python raw.py
      How many pounds does your suitcase weigh? 677
      There is a $25 charge for luggage that heavy.
      Thank you for your business.

  2. alan says:

    Hello, I did this steps but I have problem with sublimeREPL, when I go to tools->sublimeREPL->python->python-run current file
    this error appears:
    windowsError(2,’Le fichier sp\xe9cifi\xe9 est introuvable

    I try for hours to find the solution but I failed.. Can you help me?

Leave a Reply

Your email address will not be published. Required fields are marked *

1 Flares Twitter 1 Facebook 0 Google+ 0 Pin It Share 0 LinkedIn 0 Reddit 0 StumbleUpon 0 1 Flares ×