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

5

我尝试使用$ 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 返回

python@3.8: 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/python@3.8.rb
License: Python-2.0
==> Dependencies
Build: pkg-config ✔
Required: gdbm ✔, openssl@1.1 ✔, 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/python@3.8/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)


4
“python not installed” 表示 Python 没有 通过 Homebrew 安装 - khelwood
1
“brew info python” 有什么信息? - MisterMiyagi
@khelwood 这是一台相当新的 Mac 机器,我想我只使用了 Homebrew。我猜可能是我不小心没有安装它... - tim_xyz
@MisterMiyagi,我已经在上面添加了brew info python返回的内容。说实话,这超出了我的理解范围。 - tim_xyz
1
重要的部分是“未安装”行。请在尝试升级之前先安装它。 - MisterMiyagi
1个回答

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

我以为Python已经被安装了,但那只是系统自带的版本,不是通过brew安装的。

错误信息"Error: python not installed" 意味着Python没有通过brew安装。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接