当我在终端中运行python3时,表明我正在运行python 2.7.10。我更新了一个pip包和conda包,因为我无法运行python3。我确信如果python3成功运行,python 2正在以编写“ print“ hello”“的方式运行,这是不应该的。
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正在运行,则此方法不起作用。 我要如何运行python3? 我需要设置环境路径还是其他?
答案 0 :(得分:0)
好消息。我已经解决了问题(使用其他论坛文章) 在终端中将别名设置为其他python版本可以解决此错误。
$ alias python='python3.7'
$ alias python2='python2'
$ alias python3='python3.7'
因此,当我在终端中键入“ python”时,将调用python3。不确定我的问题是别名还是路径问题,因为在遇到问题之前我还不了解这两个概念。
例如,在输入python3.7或3.5之前,请确保已安装python版本。
此外,仅python3无法正常工作。 输入python3.1或python3.3