Brew升级python返回“未安装python”

问题描述

我正在尝试使用$ brew upgrade python从“ Python 3.7.3”升级到“ Python 3.8”。但是当我尝试时,brew返回:

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 2 formulae.

Error: python not installed

我知道已经安装了python,因为我已经使用了几个月了。我可以通过运行which python3

来确认这一点
/usr/bin/python3

还有python3 --version

Python 3.7.3

我不知道是什么原因造成的?

问题可能是python --version仍指向python2 Python 2.7.16


更新

我还确认我已经运行过brew cleanupbrew doctor

brew info python返回

[email protected]: stable 3.8.5 (bottled)
Interpreted,interactive,object-oriented programming language
https://www.python.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/[email protected]
License: Python-2.0
==> Dependencies
Build: pkg-configrequired: gdbm ✔,[email protected] ✔,readline ✔,sqlite ✔,xz ✔
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`,`python-config`,`pip` etc. pointing to
`python3`,`python3-config`,`pip3` etc.,respectively,have been installed into
  /usr/local/opt/[email protected]/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 587,815 (30 days),1,615,984 (90 days),2,710,078 (365 days)
install-on-request: 187,760 (30 days),307,168 (90 days),343,355 (365 days)
build-error: 0 (30 days)

解决方法

解决方案是使用brew安装python。

brew install python

我认为它已经安装了,但这是系统版本(不是brew)。

错误Error: python not installed暗示brew尚未安装python。