有没有办法在 Atom 中使用多个版本的 Python 运行 Python 脚本?

Is there a way to run Python scrips in Atom with multiple versions of Python?

我正在使用 Atom 文本编辑器编写 Python 程序。我通常使用命令 atom script_name.py 开始一个新脚本,然后 Atom 文本编辑器打开。您可以使用命令 cmd+i 使用包 script 执行脚本。 (参见 https://atom.io/packages/script

有些情况我想使用 Python 2.7,有些情况我更喜欢使用 Python 3.4

据我了解,唯一的方法是手动更改 Python 版本的 $PATH。在我的例子中,Python 3.4 的路径是 /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4 Python 2.7 的路径是 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7.

除了每次手动更改 $PATH 之外,还有其他方法吗?我可以使用另一个包吗?

编辑:可能有些混乱。我认为您应该能够在 Atom 脚本中使用 python2.7python3.4 运行。在命令行中,只需为 python2.7python3.4 运行 python3 script.py 执行 python script.py

如果可执行文件具有不同的名称,您可以在 PATH 中同时拥有两个版本。

就我而言,我有:

python 2.7 (python): /usr/bin/python

python 3 (python3): /usr/local/bin/python3