【问题标题】:cannot install python using brew无法使用 brew 安装 python
【发布时间】:2016-10-12 19:32:01
【问题描述】:

尝试使用以下命令安装python:

brew install python

但不幸的是,我收到以下错误:

>brew install python
==> Downloading https://homebrew.bintray.com/bottles/python-2.7.12_2.el_capitan.
Already downloaded: /Users/maguerra/Library/Caches/Homebrew/python-2.7.12_2.el_capitan.bottle.tar.gz
==> Pouring python-2.7.12_2.el_capitan.bottle.tar.gz
==> Using the sandbox
==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg insta
Last 15 lines from /Users/maguerra/Library/Logs/Homebrew/python/post_install.01.python:
copying setuptools/command/rotate.py -> build/lib/setuptools/command
copying setuptools/command/saveopts.py -> build/lib/setuptools/command
copying setuptools/command/sdist.py -> build/lib/setuptools/command
copying setuptools/command/setopt.py -> build/lib/setuptools/command
copying setuptools/command/test.py -> build/lib/setuptools/command
copying setuptools/command/upload.py -> build/lib/setuptools/command
copying setuptools/command/upload_docs.py -> build/lib/setuptools/command
creating build/lib/setuptools/extern
copying setuptools/extern/__init__.py -> build/lib/setuptools/extern
copying setuptools/script (dev).tmpl -> build/lib/setuptools
copying setuptools/script.tmpl -> build/lib/setuptools
running install_lib
copying build/lib/easy_install.py -> /usr/local/lib/python2.7/site-packages
copying build/lib/pkg_resources/__init__.py -> /usr/local/lib/python2.7/site-packages/pkg_resources
error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-  packages/pkg_resources/__init__.py'
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python`

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

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and Python.md

.app bundles were installed.
Run `brew linkapps python` to symlink these to /Applications.
==> Summary
????  /usr/local/Cellar/python/2.7.12_2: 3,150 files, 42.5M

以前有没有人看到过这个问题,或者现在如何解决这个问题以完成 python 安装过程?

【问题讨论】:

    标签: python installation homebrew


    【解决方案1】:

    错误消息说你没有权限在/usr/local/lib/python2.7/site-packages/pkg_resources下写。

    以下步骤应该有效:

    1. 删除损坏的 Python 安装:

      brew uninstall python
      
    2. 确保您拥有该目录:

      sudo chown -R $(whoami):admin /usr/local/lib/python2.7/site-packages
      
    3. 重试:

      brew install python
      

    【讨论】:

    • 我必须更新我的路径:sudo chown -R $(whoami):admin /Users/YourUser/Library/Python/2.7/lib/python/site-packages 才能找到它。
    【解决方案2】:

    使用 Brew 安装 Python3 在终端输入 brew 命令

    brew install python3
    

    可选,PATH 环境 设置 PATH 环境变量,如果你使用 HomeBrew 安装 Python3,那么 HomeBrew 已经添加了 PATH。

    如果可以从终端启动 python3,请不要更改 PATH 环境。

    将以下行添加到您的 ~/.profile 文件中

    export PATH=/usr/local/bin:/usr/local/sbin:$PATH
    

    通常你的 Python 安装目录是这样的,把它添加到你的 PATH 中

    PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
    

    【讨论】:

      猜你喜欢
      • 2021-01-27
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-28
      相关资源
      最近更新 更多