Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

turboLT

macrumors newbie
Original poster
Jul 8, 2013
6
0
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!
 
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.
 
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
 
Learn Python the Hard Way mentions that IDLE hangs on raw_input() and advises against using it (or any other IDE.)
 
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?
 
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?
 
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.
 
That's fantastic advice, thank you! I'm excited to get back to it.
 
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.
 
Fix for IDLE broken on Mac

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.