59

I use Sublime Text 2 but it won't let me enter any value when my code asks for user input. (In other words: input() in Python and gets in Ruby fail to correctly prompt me for input).

Python throws an EOFError error (what you get when user doesn't enter anything).

Simply USER INPUT isn't working in Sublime Text 2 for me.

EDIT: FOR EXAMPLE

try:
    text = input('Enter something: ')
    print text
except EOFError:
    print('\nEOFError')

=> Enter something: #cannot enter anything to var "text"
=> EOFError
=> [Finished]
roflol
  • 637
  • 2
  • 7
  • 9

2 Answers2

74

Sublime text doesn't support that. But you can get around it (at least in python) by using SublimeREPL, I use this for everything, it works pretty great. Its a little cooky though, as the tab is still editable like a normal sublime tab (which is good and bad)...

It also allows you to run the interpreter in multiple tabs, its basically awesome.

To install it you need package control this lets you easily install plugins. To get it go here, and follow the instructions. Once thats done:

  • in Sublime press ctrl + shift + P (linux command in ST for 'goto anything').
  • Type in 'install',
  • click on 'sublime package control: install package'.
  • Then select SublimeREPL. It will install it automatically.
  • To use it go to Tools>sublimerepl>python from the menus.

To make the default build system SublimeREPL, you can follow these instructions.

Void
  • 583
  • 7
  • 14
fraxel
  • 34,470
  • 11
  • 98
  • 102
  • 2
    @pnemi - updated with instructions. you'll like package control, it gives you access to a heap of handy plugins. – fraxel May 15 '12 at 16:58
  • How to make it looking like this - http://wuub.net/sublimerepl/debian2.png ? And how to bind some keys to it? – roflol May 15 '12 at 17:09
  • 1
    @pnemi - once you've installed it, goto `view>layout>rows:2`, this splits the screen. Then goto ` Tools>sublimerepl>python>python` this opens the new interpreter window, which you can then drag to the bottom view. – fraxel May 15 '12 at 17:13
  • 1
    That probably doesn't suit me :-/ Is there any other great editor like ST2 which skips this hassle and these problems? Supporting HTML/RUBY/PYTHON etc? – roflol May 15 '12 at 17:24
  • 1
    @pnemi - I guess its quite a personal taste thing. I've used a bunch of other editors, but I had issues with all of them. Pycharm is quite contemporary, and had quite a good feel, but i don't know if it does ruby... Or you could use a more basic editor and shell combo.. I suggest sticking with ST2, its worth it! Good luck regardless ;) – fraxel May 15 '12 at 17:32
  • Ctrl+Shift+P allowed me to access Package Control on my Win7 box. – Piper Nov 21 '12 at 19:29
  • Use TextWrangler. It opens up a terminal window, and allows you to debug. People have been coercing me to use sublime, and I do like editing multiple lines at once, but lacking an easy ability to run scripts from sublime makes it substandard. – MagicLAMP Sep 24 '15 at 03:22
  • 11
    But it's not working on pressing `ctrl+B`, I had to go the the tools>>options , Python - run current file. How to make it run automatically? – User Oct 21 '15 at 14:49
  • 3
    I am wondering the same thing @user . If there is a way to hook this up automatically – SandBag_1996 Feb 03 '16 at 22:40
  • Mathias711 @fraxel Is there a way/shortcut to run it quickly as asked by user? – user7375520 Apr 18 '17 at 06:31
  • 1
    To make Ctrl+B work with this, see https://stackoverflow.com/questions/19732006/how-to-run-python-code-on-sublimerepl/23722631#23722631. – Void Nov 18 '20 at 22:07
12

Since, Sublime not directly support for input console. So, it is easy to get input in Sublime with following extra steps:

  1. Make sure that you have install Package control in Sublime.
    • If you have no install Package control then, go to here then, click install Now button (top right) copy those code and paste it in your Console (make sure you have tick the Show Console option) and Press Enter. (after that restart sublime)
  2. Go to ->Command Palette(Cltr + Shift + p) click "Package Control: Install Package"
  3. Search : "SublimeRepl" and wait for Installing.
  4. Once, it is Installed, ,Restart Sublime
    • Go to Tools you will see ""SublimeRepl" option at the bottom (which indicates that it is successfully installed in your sublime)
  5. To run python scripts: Go to Tools->SublimeRepl->Python->Python-RUNcurrentfile option and your code is run in new Repl Tab.

Note: This works fine for sublimeText3 (windows )

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
susan097
  • 3,500
  • 1
  • 23
  • 30