我遇到了同样的问题并做了一些研究。我发现有人在azure/cli存储库下为同一问题创建了一个错误。您可以在此处找到该问题。我在这里提供了相同的解决方案,这非常简单并解决了我的问题:
很可能 Brew 坏了,需要一些修补或修复。所以运行brew doctor
命令,它会给你一个关于正在发生的事情的总结。以下是我得到的:
mymac:bin sidmishra$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: The following directories do not exist:
/usr/local/sbin
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/LibSideSyncOSX9.dylib
/usr/local/lib/ss_conn_lib.dylib
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:
python
该命令的绝妙之brew doctor
处在于,它不仅可以告诉您问题,还可以在大多数情况下为您提供解决方案步骤。因此,我运行了 brew 建议的所有命令并链接我运行了以下命令:
brew link python
上面的命令给我一个错误:
mymac$ brew link python
Linking /usr/local/Cellar/python/3.7.1... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks/Python.framework
我当前的用户似乎/urs/local/Frameworks
没有足够的权限。因此,我运行了以下命令并为当前用户提供了足够的权限:
sudo chown -R $(whoami) /usr/local/Frameworks/
运行上述命令后,我再次运行链接命令,它工作了!!!
mymac$ brew link python
Linking /usr/local/Cellar/python/3.7.1... 1 symlinks created
现在运行以下命令来获取当前选择的 python 版本:
python --version
上面的命令应该给你3.7.1
(截至 2018 年 12 月 21 日)或 python 的新版本。您的 Mac 可能会python2
默认设置。如果版本不是python3
,那么您必须执行几个步骤才能使用最新python3
的python2
版本。以下是步骤:
使用外壳:
或
使用自制软件:
运行以下命令以取消链接 python2 和链接 python3:
mymac$ brew unlink python@2
mymac$ brew link python@3
上面将取消链接python2并链接python3。
希望你们中的一些人能从这个答案中得到帮助。
再会!!!