Python 3 已经安装但是 python -V returns python 2
Python 3 already installed but python -V returns python 2
我尝试使用自制软件安装 python 3。它告诉我它已经安装了。
每当我 运行 a python test.py 它使用 python2。如何将默认值更改为 python 3?
如果 Python 出现在命令下,则表示已安装。它是什么版本?让我们检查一下:
$ brew info python
python: stable 3.7.3 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.2_1 (8,437 files, 118MB) *
## further output not included ##
Homebrew 维护者已将默认 Python 瓶更新为指向最新版本。由于 Homebrew 维护者在更新版本方面比我们大多数人更可靠,因此您可以使用 Homebrew 版本的 Python 3 使用以下命令:
$ brew update && brew upgrade python
现在您必须将别名指向 Homebrew 管理的 Python 副本:
# If you added the previous alias, use a text editor to update the line to the following.
alias python=/usr/local/bin/python3
要确保以上路径指向 Homebrew 在您的环境中安装 Python 的位置,您可以 运行 brew info python 并查找路径信息。
我尝试使用自制软件安装 python 3。它告诉我它已经安装了。
每当我 运行 a python test.py 它使用 python2。如何将默认值更改为 python 3?
如果 Python 出现在命令下,则表示已安装。它是什么版本?让我们检查一下:
$ brew info python
python: stable 3.7.3 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.2_1 (8,437 files, 118MB) *
## further output not included ##
Homebrew 维护者已将默认 Python 瓶更新为指向最新版本。由于 Homebrew 维护者在更新版本方面比我们大多数人更可靠,因此您可以使用 Homebrew 版本的 Python 3 使用以下命令:
$ brew update && brew upgrade python
现在您必须将别名指向 Homebrew 管理的 Python 副本:
# If you added the previous alias, use a text editor to update the line to the following.
alias python=/usr/local/bin/python3
要确保以上路径指向 Homebrew 在您的环境中安装 Python 的位置,您可以 运行 brew info python 并查找路径信息。