Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Atom to run Python3 scripts?

In my terminal, I type $ which python3, outputting

/opt/local/bin/python3

I would like to configure Atom to run Python3 scripts. In my Atom Config, I have

runner:
python: "/opt/local/bin/python3"

However, if I run the following script in some script named filename.py,

import sys
print(sys.version)

I get the following output:

2.7.11 (default, Feb 18 2016, 22:00:44) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]

How exactly does one set up the PATH for Python3.x scripts to run correctly? Is there a different package I could use?

like image 246
EB2127 Avatar asked Feb 22 '16 05:02

EB2127


People also ask

How do I run python code in Atom with script?

In order to run Python in the Atom Code Editor, we have to install the corresponding script package. We can install the script package from this link. Alternatively, we can click on the Install a Package button and search for the script package.

How do I set python as default in Atom?

You may either open Atom and in the bottom right corner click on “Plain Text” and change the language to “Python” or you can save the file you want to work in with a “. py” at the end and Atom will automatically know you are writing Python code. Once you have done this, write some code as a test.


2 Answers

Go to the Atom's menu bar -> Packages -> Script -> Configure Script (Or, you can use the shortcut Shift+Ctrl+Alt+O)

Then type python3 to the Command space. Hopefully, it will work.

like image 55
Terry Avatar answered Oct 13 '22 18:10

Terry


i am using "script" package (3.18.1 by rgbkrk) to run code inside atom and this is how i fixed it

  1. open package settings -> view code
  2. open lib -> grammars -> python.coffee
  3. change from python to python3 in those two places 'Selection Based' and 'File Based'
like image 24
user3365784 Avatar answered Oct 13 '22 16:10

user3365784