How to configure Atom to run Python3 scripts?

匿名 (未验证) 提交于 2019-12-03 02:03:01

问题:

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?

回答1:

If you are using Mac OS X, use the directory on the terminal to open the file.

Select the file python3, right click and select "get info". Select the directory from "Where:" and past it in Atom.

As Terry told you:

Then type python3 to the Command space.

It should work, Nahuel :)



回答2:

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

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

Best, Terry



回答3:

You can use the Atom package atom-python-run to launch python code from Atom, the python version can be configured in the package settings. By default atom-python-run uses the syntax python {file}. If the python command on your system is not yet pointing to python3, just replace the setting and write python3 {file}.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!