安装了Python3,但是无法链接Python3

6

我正在尝试通过 brew 安装 Python3

==> Downloading https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
Already downloaded: /Users/leongaban/Library/Caches/Homebrew/python3-3.6.4.tar.xz
==> ./configure --prefix=/usr/local/Cellar/python3/3.6.4_2 --enable-ipv6 --datarootdir=/usr/local/Cellar/python3/3.6.4_2/shar
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.6.4_2
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.6.4_2/share/python3
==> Downloading https://files.pythonhosted.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/se
Already downloaded: /Users/leongaban/Library/Caches/Homebrew/python3--setuptools-36.5.0.zip
==> Downloading https://files.pythonhosted.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pi
Already downloaded: /Users/leongaban/Library/Caches/Homebrew/python3--pip-9.0.1.tar.gz
==> Downloading https://files.pythonhosted.org/packages/fa/b4/f9886517624a4dcb81a1d766f68034344b7565db69f13d52697222daeb72/wh
Already downloaded: /Users/leongaban/Library/Caches/Homebrew/python3--wheel-0.30.0.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
➜  ~ python -V
Python 2.7.10
➜  ~ brew link python3 
Linking /usr/local/Cellar/python3/3.6.4_2... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

我发现了这个答案,并按照步骤进行操作,但仍然遇到问题,无法连接python3,我的 python -V 仍然显示为2.7brew install python3 didn't install pip3
3个回答

5
sudo chown -R $(whoami) /usr/local

这将赋予创建符号链接的权限,从而解决链接问题。

这会在使用brew的多个用户系统上破坏brew,不是吗? - ofloveandhate
1
当我尝试这个时,我收到错误信息 chown: /usr/local: 操作不允许。有任何想法为什么会出现这种情况? - lucas
5
之后我尝试手动创建目录(sudo mkdir /usr/local/Frameworks),然后更改新目录的权限(sudo chown -R $(whoami) /usr/local/Frameworks)。这最终使我能够成功运行 brew link python 而没有出现错误。 - lucas

0
啊哈!我刚刚把它修好了。我是在/usr/local/lib文件夹中创建了Frameworks文件夹,而不仅仅是/usr/local/文件夹。
移动文件夹后重新运行以下命令:sudo chown -R $(whoami) $(brew --prefix)/* 现在,我能够brew link python3成功了。

0

我在这里复制@lucas的评论以增加可见性。这对我有用。

  1. 手动创建Frameworks目录。
sudo mkdir /usr/local/Frameworks
  1. 更改新目录的权限。
sudo chown -R $(whoami) /usr/local/Frameworks
  1. 运行brew link命令以完成符号链接。
brew link python3

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