如何在终端调用 "python3" 时停止 Python 2.7 运行?

How to stop Python 2.7 running when "python3" is called in terminal?

当我在终端中 运行 python3 时,它表明我正在 运行ning Python 2.7.10。我更新了 pip 包和 conda 包,因为我无法 运行ning python3。我确信 python 2 是 运行ning,因为写作 'print "hello"' 是不应该的,如果 python3 成功 运行。

Daves-MBP:Desktop dave$ python3

Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin

Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello"
hello

如果 python3 是 运行ning,这将不起作用。 如何在需要时获得 python3 运行ning? 我需要设置环境路径还是其他什么?

好消息。我自己解决了这个问题(使用不同的论坛文章) 在终端中将别名设置为不同的 python 版本可解决此错误。

$ alias python='python3.7'
$ alias python2='python2'
$ alias python3='python3.7'

因此,当我在终端中键入 'python' 时,会调用 python3。不确定我的问题是别名问题还是路径问题,因为在遇到问题之前我不知道这两个概念。

确保在输入 python3.7 或 3.5 之前安装了 python 版本。

此外,python3 单独使用是行不通的。 输入 python3.1 或 python3.3