brew尝试"将python3迁移到python"每次

时间:2018-03-03 22:51:53

标签: python-3.x macos homebrew

我相信python环境是我的Mac有点乱... 每次我使用brew时,它都会首先执行此操作:

==> Migrating python3 to python
==> Unlinking python3
==> Unlinking python
Error: Error occurred while migrating.
Permission denied @ unlink_internal - /usr/local/share/python
Backing up...
Error: Permission denied @ unlink_internal - /usr/local/share/python

在我的Mac中,我有:

  • python2,由' python'引用,并由它安装 蟒蛇束。
  • python3,由' python3'引用,它是' 由brew安装。

实际上我在/ usr / local / bin中为python3创建了一个符号链接,这是我能在机器中区分python / python3的最好方法......但最近它只是搞砸了......

我尝试find / -name "python3",结果如下:

/Users/liuziqi/anaconda/lib/python2.7/site-packages/astroid/tests/testdata/python3
/Users/liuziqi/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/crcmod/python3
/Users/liuziqi/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/httplib2/python3
/Users/liuziqi/google-cloud-sdk/platform/gsutil/third_party/crcmod/python3
/Users/liuziqi/google-cloud-sdk/platform/gsutil/third_party/httplib2/python3
/usr/local/Cellar/python3
/usr/local/Cellar/python3/3.6.1/bin/python3
/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/Cellar/python3/3.6.4_2/bin/python3
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/python3
/usr/local/lib/python3.6/site-packages/astroid/tests/testdata/python3
/usr/local/opt/python3

我之前使用的python3是/usr/local/Cellar/python3/3.6.1/bin/python3,我创建了一个指向/usr/local/bin的链接

1 个答案:

答案 0 :(得分:1)

您必须使用以下命令修复权限:

sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew

如果您是系统中唯一的Homebrew用户,则效果很好。如果第三方工具正在等待/ usr / local上的其他权限,则可能会导致问题。但是,我使用这些设置多年没有问题。有关详细信息,请参阅How to fix homebrew permissions?