Home Download Buy Blog Forum Support

Python - Using input?

Python - Using input?

Postby linkey11 on Sun Feb 19, 2012 8:04 pm

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:

Code: Select all
word = input('Word: ')
print word


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

Code: Select all
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 (http://www.sublimetext.com/forum/viewtopic.php?f=3&t=1519&p=6908&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?
linkey11
 
Posts: 6
Joined: Sun Feb 19, 2012 7:47 pm

Re: Python - Using input?

Postby jps on Mon Feb 20, 2012 11:40 am

There's no support for this
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Python - Using input?

Postby nickcw123 on Wed Feb 22, 2012 10:13 am

I also think its a deal breaker.

I cant see why this feature is not going to be added.
nickcw123
 
Posts: 8
Joined: Tue Feb 07, 2012 2:49 pm

Re: Python - Using input?

Postby wuub on Wed Feb 22, 2012 10:44 am

nickcw123 wrote:I also think its a deal breaker.


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
Image
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: Python - Using input?

Postby linkey11 on Thu Feb 23, 2012 1:48 am

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.
linkey11
 
Posts: 6
Joined: Sun Feb 19, 2012 7:47 pm

Re: Python - Using input?

Postby facelessuser on Thu Feb 23, 2012 2:42 am

Probably because Python is not in your system path.
facelessuser
 
Posts: 1574
Joined: Tue Apr 05, 2011 7:38 pm

Re: Python - Using input?

Postby wuub on Thu Feb 23, 2012 9:14 am

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
Code: Select all
"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.
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: Python - Using input?

Postby linkey11 on Fri Feb 24, 2012 4:29 am

wuub wrote: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
Code: Select all
"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.


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?
linkey11
 
Posts: 6
Joined: Sun Feb 19, 2012 7:47 pm

Re: Python - Using input?

Postby wuub on Fri Feb 24, 2012 9:20 am

Leave Main.sublime-menu alone then :)

Add your python location to the **SYSTEM** path here, restart sublime and everything should work
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: Python - Using input?

Postby linkey11 on Sat Feb 25, 2012 2:34 am

Excellent, thanks!
linkey11
 
Posts: 6
Joined: Sun Feb 19, 2012 7:47 pm

Next

Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 28 guests