Sublime Forum

Python - Using input?

#1

Up until a few days ago I was using IDLE for my Python code - but then I stumbled upon Sublime Text 2. I love how sleek and fast it is, but I immediately ran into some problems with my code (Iā€™m using Python 2.7.2) I tried:

word = input('Word: ')
print word

And when I tried to run with the build set to Python + F7 I got:

Word: Traceback (most recent call last):
  File "C:\Users\Daniel\Dropbox\Programming\Neo\NQ2AP\thing.bat", line 1, in <module>
    word = input('Word: ')
EOFError: EOF when reading a line
[Finished]

Iā€™ve read multiple topics/pages around these forums and the internet of input not working because stdin isnā€™t connected to anything (https://forum.sublimetext.com/t/strange-is-this-a-bug/1136/1&hilit=python+input#wrap) this is pretty much a deal breaker for me editing my code in Sublime, constantly switching between Sublime and IDLE doesnā€™t seem to be the most efficient way of doing things. Is there any way to give input to my script in a similar fashion as the console receives it?

0 Likes

OSX SL, Python 2.7.2
OSX SL, Python 2.7.2
#2

Thereā€™s no support for this

0 Likes

#3

I also think its a deal breaker.

I cant see why this feature is not going to be added.

0 Likes

#4

Try SublimeREPL (1.0.12) (via Package Controll). And then Tools -> SublimeREPL -> Python -> Python - RUN current file
It is not foolproof, but maybe itā€™ll work in your case

0 Likes

#5

For some reason I canā€™t get SublimeREPL to work, whenever I try to use the interpreter through it I get: ā€œ[Error 2] The system cannot find the file specifiedā€ although it works on my Windows Vista Machine.

0 Likes

#6

Probably because Python is not in your system path.

0 Likes

#7

Yup. 99% itā€™s a PATH problem.
Check if Tools -> Build System -> Python is working, and if itā€™s not fix your system path.

There is also a way to fix it using extend_env in Main.sublime-menu

"extend_env": {"osx": {"PATH": "{PATH}:/usr/local/bin"}, "linux": {"PATH": "{PATH}:/usr/local/bin"}, "windows": {}},

But it will get overwritten during next update.
Iā€™ll push a workaround for this common PATH problem soon that will survive package updates.

0 Likes

#8

[quote=ā€œwuubā€]Yup. 99% itā€™s a PATH problem.
Check if Tools -> Build System -> Python is working, and if itā€™s not fix your system path.

There is also a way to fix it using extend_env in Main.sublime-menu

"extend_env": {"osx": {"PATH": "{PATH}:/usr/local/bin"}, "linux": {"PATH": "{PATH}:/usr/local/bin"}, "windows": {}},

But it will get overwritten during next update.
Iā€™ll push a workaround for this common PATH problem soon that will survive package updates.[/quote]

Iā€™ve found the Main.sublime-menu, but have no idea about how the indentations and brackets should be formatted. Could you post an example?

0 Likes

#9

Leave Main.sublime-menu alone then :smile:

Add your python location to the SYSTEM path here, restart sublime and everything should work

0 Likes

#10

Excellent, thanks!

0 Likes

#11

Hi John,
Are there plans to support this ?

0 Likes

#12

[quote=ā€œwuubā€]Leave Main.sublime-menu alone then :smile:

Add your python location to the SYSTEM path here, restart sublime and everything should work[/quote]

Thanks ,it also solve my peoblem.good job

0 Likes

#13

This didnā€™t fix my problem, Iā€™ve been trying to get this to work for hours now Q_Q any suggestions would be greatly appreciated. using sublime 3

0 Likes