Python script with input not running unless I execute it on terminal

2.1k views Asked by At

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!

2

There are 2 answers

2
HansGroober On

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.

0
LinkBerest On

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.