无法在 Mojave 中冲泡升级 Python

Unable to brew upgrade Python in Mojave

I 运行 brew outdated in macOS Mojave 10.14.2 并确定 pythonpython@2 已过时。当我 运行 brew upgrade 时,两者都失败了。例如 python@2:

==> Upgrading python@2 
==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.15_2.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring python@2-2.7.15_2.mojave.bottle.tar.gz
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

I 运行 brew doctor 并建议 brew link 但这仍然失败并出现相同的权限错误:

Linking /usr/local/Cellar/python@2/2.7.15_2... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

This post建议给父目录g运行t权限,但是我想了解为什么会出现这种情况,找到解决方案学习。

我找到了答案here。根据 post,我不得不先 sudo mkdir /usr/local/Frameworks 创建丢失的目录,然后 sudo chown -R $(whoami) $(brew --prefix)/* 因为 sudo chown -R $(whoami) /usr/local 在 Mojave 和 High Sierra 之前不再工作。在那之后我能够 brew link pythonbrew link python@2