Execute Python scripts with input()

Hi all,
I am new to Atom and coding in general. On my HND I have used Sublime Text 3 so taking a look at Atom.
So far, so good.
I have decided to start learning Python.
I created my first script which just asks a user for their name and age. I have used Pythons input() function to request this information.

I installed the package Script https://atom.io/packages/script

This ran the script well but couldn’t deal with the input.

I have also tried a number of other options but havn’t had any success.
Any ideas how to build and execute scripts from within Atom. I don’t mind if it just simply saved the script and opened Pythons IDLE at a minimun.

I think I am a long way of from being able to build such a thing.

(maybe sometime in the future)

1 Like

I understand you’ve already found the script package which is referred to in the FAQ:

Honestly, Atom is a text editor. It isn’t designed out-of-the-box to build or execute code. If one of the many packages can’t help, you can always execute Python scripts from the command line.

This is true ATOM is only a test editor. With multiple plugins it eases the process of only saving the file and exeucting separately via command line. There is no way now to execute scripts with input. The only solution to accept input to python scripts is via command line.Hope, script package add this feature in future for our help.


1 Like

What you can do is get a terminal package so that you can use the command line from within Atom.

1 Like

Run a python source file in a Linux Terminal with python-run-terminalnx

The best way I’ve found to easily run a python command with a keystroke is the following plugin

Others will work fine but most will not accept input properly.

You can modify the source of the plugin very easily from the atom interface to support python 2 or 3.

1 Like

Could you please explain step-by-step (or share a link) how to change python2 to python3?
I’ve read half of internet but found no solution that would work for me with script-runner.
I’d really appreciate. Thanks in advance.

1 Like

script-runner doesn’t have a config setting to change the command, but you can change which version of Python responds to the python command by changing the order of the folders in your PATH. What operating system are you on?

Mac OS, El Capitan

What do you see when you type python --version into the Terminal?

I see: Python 2.7.10
And, of course, I have python3 installed plus homebrew.
Sublime Text now runs Python 3 scripts but Atom still resists.

Your attribution is wrong. Atom isn’t resisting anything. script-runner is using the command python, and your computer is set up so that Python 2 is the default. If you want to continue using script-runner, you have to solve the issue outside of Atom, such as by using pyenv.

I know it’s not resisting. Just joking. :wink:
Anyway, I’ll give pyenv a try. Thanks.

DamnedScholar - thanks for help.
Tried pyenv but no success.
I decided to give up and stick with Sublime Text, but I really appreciate your help.

Honestly, how can you guys miss this package? It is featured in atom and on the atom packages site.

The command CTRL-X doesn’t work for me on Mac when I install that plugin. What’s up with that?

I have same problem
I am using Atom to learn Python
the input is not working as the example below,
name = input (“Enter name:”)
print ("Hello " + name)

Any suggestions how to make work, please?
Did you get any solution?

Like has been previously mentioned in the thread, you can use a terminal package, script-runner, or hydrogen. Some of the other packages (you don’t specify which one you’re using) haven’t been constructed to receive input.


I used script, and both you mentioned are not working too

script is unable to receive input because the author of the package didn’t write it so that it could. If you are having trouble installing or using a package, you need to provide exactly what steps you have taken and what results you are seeing. Have you tried the package termination? It creates a terminal inside Atom (the first thing I mentioned), has no special setup requirements, and gives you easy access to the Python CLI inside Atom.