IDLE hangs on raw_input()

Discussion in 'Mac Programming' started by turboLT, Jul 10, 2013.

  1. macrumors newbie

    Jul 8, 2013
    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.

    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!
  2. macrumors 68040

    Feb 2, 2008
    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.
  3. thread starter macrumors newbie

    Jul 8, 2013
    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
  4. macrumors 604


    Nov 26, 2007
    Learn Python the Hard Way mentions that IDLE hangs on raw_input() and advises against using it (or any other IDE.)
  5. thread starter macrumors newbie

    Jul 8, 2013
    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?
  6. macrumors 68040

    Feb 2, 2008
    Wow, that sucks.

    FWIW I interpreted "idle" in it's litteral meaning here, lol. :cool:
  7. thread starter macrumors newbie

    Jul 8, 2013
    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?
  8. macrumors 604


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

    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.
  9. thread starter macrumors newbie

    Jul 8, 2013
    That's fantastic advice, thank you! I'm excited to get back to it.
  10. macrumors newbie

    May 8, 2011
    San Jose
    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.
  11. macrumors newbie

    Oct 9, 2013
    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

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

Share This Page