无法通过 Homebrew 安装 Python3

Unable to install Python3 via Homebrew

我想通过 Homebrew 安装 python 3。这是我得到的错误:

Error: You must `brew link xz gdbm' before python3 can be installed

现在当我 'brew link xz gdbm' 我得到这个:

Linking /usr/local/Cellar/gdbm/1.11... Error: Could not symlink include/gdbm.h/usr/local/include is not writable.

我尝试了以下选项来解决这个问题:

sudo chown -R $USER /usr/local/bin/include
usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...
   chown [-fhv] [-R [-H | -L | -P]] :group file ...

在此之后,我尝试再次安装 python3,但我遇到了同样的错误。请帮忙。

/usr/local/include is not writable.

sudo chown -R $USER /usr/local/bin/include

您要 chown 的目录是 /usr/local/include,或者 /usr/local 正确。

我遇到了同样的问题。 运行

brew doctor

(如果 brew 旧时,您可能还需要使用命令 brew update 更新它) 清除警告后 python 安装应该会顺利进行。

请注意,您可以 运行 多次冲泡医生,直到所有警告都消失。

运行

    brew doctor

然后你会看到这样的诊断:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run brew link on these:

  makedepend

这意味着您可以通过 运行 宁此代码来修复:

 brew link makedepand

所以现在可以了。

 brew install pyenv