PDA

View Full Version : IDLE hangs on raw_input()




turboLT
Jul 10, 2013, 11:09 AM
Hi All,

On my wife's 2012 Macbook Air I'm trying to finish up a python problem set, but every time I run a script it IDLE hangs on raw_input().

At first I thought it was me, but I used the professor's solution and that hung too.

Ex:
number = float(raw_input("Enter a number: "))
print number

will output in IDLE:

Enter a number:

then just spinning pinwheel and no way to enter anything. Thoughts?
thanks in advance for your help!



subsonix
Jul 10, 2013, 11:25 AM
It seems like you are leaving out some crucial details here. I tried what you posted in the Python live interpreter and had no issues with it.

turboLT
Jul 10, 2013, 11:36 AM
Ill happily supply anything relevant. I can't figure it out either - the same code worked for me on a 2008 MacBook until it died last weekend. Ill post the python version momentarily

ArtOfWarfare
Jul 10, 2013, 11:44 AM
Learn Python the Hard Way mentions that IDLE hangs on raw_input() and advises against using it (or any other IDE.)

turboLT
Jul 10, 2013, 11:46 AM
Python 2.7.2 on OSX 10.8.3

----------

Interesting re the hanging. The MIT class says to only use raw_input() so I wonder if I should just convert it all to input()? Doesn't input() mean something different in python 3.x?

subsonix
Jul 10, 2013, 11:48 AM
Learn Python the Hard Way mentions that IDLE hangs on raw_input() and advises against using it (or any other IDE.)

Wow, that sucks.

FWIW I interpreted "idle" in it's litteral meaning here, lol. :cool:

turboLT
Jul 10, 2013, 12:01 PM
So if you're not supposed to use IDLE what does learn python the hard way recommend? Please bear with me as I'm super new to Python.

----------

After google searches I'm guessing people are just using terminal?

ArtOfWarfare
Jul 10, 2013, 12:03 PM
So if you're not supposed to use IDLE what does learn python the hard way recommend? Please bear with me as I'm super new to Python.

A text editor and terminal. I enjoy the Sublime text editor, personally, which is available as a free download here:

http://www.sublimetext.com/2

The free trial version has no limitations at all, other than the fact it'll occasionally (about once a month) remind you of the fact that you haven't paid yet. It's $70 if you feel compelled to buy it, but there's no need to.

The idea behind this text editor and terminal approach when learning is to help the learner understand what is and isn't necessary to program, as well as what IDEs provide.

IE, many beginners learning C/Obj-C/C++ on the Mac think that their source code is in some kind of magic file that only Xcode can open and that only Xcode can run. It's not. It's in a text file, you can compile and link it without Xcode, and you can run it however you please.

turboLT
Jul 10, 2013, 12:14 PM
That's fantastic advice, thank you! I'm excited to get back to it.

SJHKMan
Jul 16, 2013, 11:23 PM
My son just encountered the same problem. Looked up the web and found that it's a known problem. The trick is not to use the F5 button to run but select the Run menu and click Run Module instead.

WorkingMatt
Oct 9, 2013, 08:42 AM
ArtOfWarfare was quite right about IDLE not working on Macs - at least an out of the box Mac.

IDLE relies on Tcl/Tk to run and Apple's standard version 8.5 is a bit knackered. So if you need to run python, write your code in a text editor (+1 for Sublime!) and execute it in Terminal thus: python filename.py

You can also fix the problem with the latest version of Python that comes with Tcl/Tk. Here's my blogpost explaining this: http://bit.ly/17W76Ks