Sublime Text 2 console input

PythonRubySublimetext2

Python Problem Overview


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]

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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)
  1. 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 )

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionroflolView Question on Stackoverflow
Solution 1 - PythonfraxelView Answer on Stackoverflow
Solution 2 - Pythonsusan097View Answer on Stackoverflow