gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:55 25 4
gpt4 key购买 nike

当我在终端中运行 python3 时,它表明我正在运行 Python 2.7.10。我更新了 pip 包和 conda 包,因为我无法运行 python3。我确信 python 2 正在运行,因为写入“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 正在运行,这应该不起作用。我怎样才能在我想要的时候让 python3 运行?我需要设置环境路径还是其他什么?

最佳答案

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

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

因此,当我在终端中输入“python”时,会调用 python3。不确定我的问题是别名还是路径问题,因为在出​​现问题之前我并不知道这两个概念。

例如,在输入 python3.7 或 3.5 之前,请确保您已安装 python 版本。

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

关于python - 在终端中调用 "python3"时如何停止 Python 2.7 运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54373425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com