【问题标题】:brew install python3 didn't install pip3brew install python3 没有安装 pip3
【发布时间】:2018-04-25 14:45:45
【问题描述】:

我使用自制软件安装了 python3,但它没有安装 pip3,或者我应该说它已安装但它无法识别命令?

这是我所做的:

brew install python3

这安装了python3,但最后抛出一个错误,说它无法链接python3并提示我运行

brew link python3

链接安装,但这会引发另一个错误:

Linking /usr/local/Cellar/python3/3.6.3... Error: Permission denied @ dir_s_mkdir - /usr/local/lib 

有谁知道如何解决这个问题? 当我跑步时:

brew info python3

上面写着:

==> Caveats
Pip, setuptools, and wheel have been installed. To update them
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>

They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

See: https://docs.brew.sh/Homebrew-and-Python.html

这让我觉得 pip3 已安装但无法识别。任何帮助表示赞赏。

信息:

操作系统 => MacOS High Sierra 10.13.1

 pip3 install twilio
-bash: pip3: command not found

【问题讨论】:

  • 我的直觉是你不需要pip3,因为pip会根据你的环境选择你当前活动的python版本。
  • 我的pip3在这里/usr/local/bin/pip3

标签: python macos python-3.x pip homebrew


【解决方案1】:

好的,我在谷歌上搜索了很多,但问题是在高山脉中 usr/local 内的所有权限都发生了变化,并且 homebrew 必须在 usr/local 内创建一些文件夹。以下是我解决所有问题的方法:

我尝试使用sudo brew install python3,但这也引发了错误 直接来自 Homebrew 告诉我它不允许使用 sudo brew.

在 /usr/local 中使用 sudo mkdir 创建我需要的文件夹:

sudo mkdir lib 
sudo mkdir Frameworks

更改 /usr/local 中的权限,以便自制软件可以访问它们:

sudo chown -R $(whoami) $(brew --prefix)/*

现在安装 python3

brew install python3

这将使您安装成功:

==> Pouring python3-3.6.3.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.3/bin --in
==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.3/bin --in
==> /usr/local/Cellar/python3/3.6.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.3/bin --in
==> Caveats
Pip, setuptools, and wheel have been installed. To update them
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>

They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

See: https://docs.brew.sh/Homebrew-and-Python.html
==> Summary
?  /usr/local/Cellar/python3/3.6.3: 3,588 files, 56.1MB

【讨论】:

  • "在高山脉中 usr/local 内的所有权限都已更改" 你有这方面的资料吗?我升级到 High Sierra 没有任何问题。
  • 我在 github 上读到这个:github.com/Homebrew/brew/issues/3228 当我列出 usr/local 目录时,大多数文件夹都需要“root”访问权限。在创建 brew 无法创建的所有文件夹后,因为我无法运行“sudo brew”,我将权限从“root”更改为“me”,brew 现在可以正常工作了。
  • 更新 - 我在我的机器上又创建了一个文件夹,local/opt。然后执行权限命令。它现在可以正常工作(python3 + pip3)。感谢您的问答。
  • 太棒了,你拯救了我的一天!
  • 按照步骤操作后,必须运行brew reinstall python3才能安装pip3
【解决方案2】:

GitHub 用户 @aether2501、commenting 在 sudo chown 解决方案中针对“Homebrew Permission Denied”problem 建议在升级到 High Sierra 后卸载/重新安装 Homebrew。

我在 High Sierra (10.13.2) 上成功使用了 @aether2501 的重新安装命令 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)",而无需先卸载 brew。

除了创建 /usr/local/Frameworks 目录和设置链接 python3 所需的必要所有权和权限外,它似乎还修复了其他目录问题。

【讨论】:

    【解决方案3】:

    我遇到了同样的问题并使用了:

    sudo -H pip3 install virtualenv
    sudo -H pip3 install virtualenvwrapper --ignore-installed six
    

    【讨论】:

      【解决方案4】:

      解决链接问题后(例如 https://github.com/Homebrew/homebrew-core/issues/19286 ),python3 已安装但 pip3 未安装。重新安装 python(例如 brew reinstall python)最终也会安装 pip3。这些步骤对我很有效。

      【讨论】:

        【解决方案5】:

        就我而言,这解决了问题:

        brew unlink python@3.9; brew link python@3.9
        

        (您可能需要将版本号替换为已安装的版本)

        【讨论】:

        • 这对我在 centos 7 上不起作用
        猜你喜欢
        • 2019-01-23
        • 2018-12-31
        • 1970-01-01
        • 1970-01-01
        • 2018-07-18
        • 1970-01-01
        • 2021-02-25
        • 2017-10-13
        • 2021-05-31
        相关资源
        最近更新 更多