Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2 console input [duplicate]

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] 
like image 625
roflol Avatar asked May 15 '12 15:05

roflol


People also ask

Does Sublime Text support inputs?

Sublime Text does not support inputting data into a program. You can up vote this feature request on: Currently you can try to install the package https://packagecontrol.io/packages/SublimeREPL and use it to run you program from a Sublime Text view.

How do I run the console in sublime?

You can run this task manually from Tools > Build. Sublime Text should automatically run your script through appropriate build system. If something doesn't work correctly go to Tools > Build System and make sure that Automatically or JavaScript is selected. Enjoy!

How do I run a Python script in Sublime Text?

By pressing Ctrl + B , Sublime 3 will run the python code inside the integrated console (provided we have saved the file with . py file extension).


1 Answers

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.

like image 83
fraxel Avatar answered Oct 14 '22 17:10

fraxel