Installing pip on macOS Sierra

前端 未结 7 1060
执念已碎
执念已碎 2021-01-31 20:11

I\'ve been trying to install pip on macOS sierra via brew, but every time it completes without installing the binaries in /usr/local/Cellar/python/2.7.13/bin.

7条回答
  •  不知归路
    2021-01-31 20:36

    For what it's worth, after upgrading to high sierra I found my machine pretty much unusable for development, even crashing plenty of times.

    Regarding python, i had a rights issue inside the site-packages folder, therefore the reinstall did not work out:

    $ brew reinstall python
    
    ==> Reinstalling python
    ==> Downloading https://homebrew.bintray.com/bottles/python-2.7.14.high_sierra.bottle.tar.gz
    Already downloaded: /Users/m/Library/Caches/Homebrew/python-2.7.14.high_sierra.bottle.tar.gz
    ==> Pouring python-2.7.14.high_sierra.bottle.tar.gz
    ==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7.14/bin --install-
    Last 15 lines from /Users/m/Library/Logs/Homebrew/python/post_install.01.python2:
    .
    .
    .
    copying build/lib/setuptools/script (dev).tmpl -> /usr/local/lib/python2.7/site-packages/setuptools
    copying build/lib/pkg_resources/_vendor/packaging/version.py -> /usr/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging
    error: could not delete '/usr/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/version.py': Permission denied
    Warning: The post-install step did not complete successfully
    ...
    

    So to fix it, I completely removed the site-packages:

    $ sudo rm -rf /usr/local/lib/python2.7/site-packages
    

    With this, reinstalling python2, and having a working pip2 again, worked like a charm:

    $ brew reinstall python
    
    $ which pip2
    /usr/local/bin/pip2
    $ which python2
    /usr/local/bin/python2
    
    $ which pip
    pip not found
    $ which python
    /usr/bin/python
    

    Hope that helps.

提交回复
热议问题