【发布时间】:2016-08-11 23:22:26
【问题描述】:
我正在使用 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 之外,还有其他方法吗?我可以使用另一个包吗?
编辑:也许有一些混乱。我认为您应该能够使用python2.7 和python3.4 在Atom 中运行脚本。在命令行中,只需对python2.7 执行python script.py 并为python3.4 运行python3 script.py。
【问题讨论】:
标签: python python-2.7 python-3.x path atom-editor