1

I am currently working on some Python exercises and I downloaded two text editors: Brackets and Atom. I use them because I like to be able to run the program I'm writing with a simple shortcut instead of saving it and then opening it on terminal (I'm on OS X Yosemite):

python ex3.py

Most programs run just fine, but whenever I include a raw_input() function inside my program and I try to run it with a shortcut from Atom or Brackets, the console output just freezes. It doesn't show any error, and I actually can run the program on Terminal just fine.

I would like to enable this feature as it is much more convenient to run my code with a shortcut without having to save and switch programs everytime.

Thanks for your help!

  • 3
    Maybe it freezes because it's waiting for your input? – Zizouz212 Jun 17 '15 at 01:02
  • It does not print the message asking for the input. And I can't type anything. – Maximiliano Santiago Jun 17 '15 at 01:08
  • Looks like it doesn't accept anything or doesn't have any `stdin`. – Zizouz212 Jun 17 '15 at 01:08
  • @Zizouz212 What do you mean? Sorry, I'm just getting started in programming and I can't figure how to google that. The script runs fine if I type `python file.py` in Terminal. But when I try to run the program from the text editors, it doesn't show anything at all, like it is still running to infinity. – Maximiliano Santiago Jun 17 '15 at 01:15
  • Are you running it inside of a shell? What's the environment like? – Zizouz212 Jun 17 '15 at 01:24
  • I think the program runs the python binary in a console: http://cl.ly/image/1c1v312e3Y2z – Maximiliano Santiago Jun 17 '15 at 01:29
  • 1
    Could you please show your code? And besides, is the Python interpreter used by Atom or Brackets the same as the one you use in the terminal? You can check the one from terminal with `which python`., but I don't really know the way for those ide's. – tomasyany Jun 17 '15 at 01:30
  • @tomasyany http://pastebin.com/Tbf8BFqr here is the code. Also, I use python 2.7.10 and I've never installed 3.x so I don't think it is a syntax issue. [Here] (http://stackoverflow.com/questions/29059161/getting-user-input-while-running-a-python-script-in-atom) is a relevant thread. – Maximiliano Santiago Jun 17 '15 at 01:35
  • 1
    @MaximilianoSantiago See the answers, but btw, I would advice to use the terminal for running your scripts, rather than the ide's interpreter. That way you have much more control on what you are using, and won't have problems like stdin not being recognized. – tomasyany Jun 17 '15 at 01:38

2 Answers2

2

With Atom, I know this is not just a python problem, I first encountered it with Ruby, it is due to the fact that Atom does not currently support STDIN.
The only current workaround (will only work for not very interactive scripts) is data file containing intended stdin input and a testing shell script eg:

#!/bin/bash
python3 test_script.py < data_file_with_input

With Brackets, its issue page shows a number of freezing issues both closed issues and open ones. So I'd start there and see if you can find a solution or open an issue yourself if you fail to.

LinkBerest
  • 1,281
  • 3
  • 22
  • 30
0

From what I can gather, Atom Script doesn't support raw_input. I can't find anything regarding Adobe Brackets, but I haven't had much success with third-party programs, so I would guess that there is a similar problem there. Is there any reason you're not using IDLE? If you're looking for a more IDE environment, I can also suggest using PyDev package in Eclipse.