Execute Python scripts with input()


#1

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)


#2

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.


#3

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.

Deb


#4

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


#5

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


#6

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.


#7

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.


#8

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?


#9

Mac OS, El Capitan


#10

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


#11

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.


#12

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.


#13

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


#14

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.


#15


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