简体   繁体   中英

How do I install pip on Mac?

I can't figure out the proper way to setup pip on my Mac. I installed python@2 on Homebrew. When I try to install virtualenv, I get this error:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/lib/python2.7/site-packages/virtualenv.pyc'
Consider using the `--user` option or check the permissions.

Here's some extra diagnostic info that may be helpful.

Jacobs-MacBook-Pro:~ jacob$ pip -V 
pip 19.0.3 from /usr/local/lib/python2.7/site-packages/pip (python 2.7) 
Jacobs-MacBook-Pro:~ jacob$ python -m pip -V 
pip 19.1.1 from /Users/jacob/Library/Python/2.7/lib/python/site-packages/pip (python 2.7) 
Jacobs-MacBook-Pro:~ jacob$ which python 
/usr/local/bin/python 
Jacobs-MacBook-Pro:~ jacob$ ls -l /usr/local/bin/python 
lrwxr-xr-x 1 jacob admin 36 Jun 19 15:36 /usr/local/bin/python -> ../Cellar/python@2/2.7.16/bin/python 

There's many opinions on the web how to set it up. Some of them are old, like using easy_install , which seems to be deprecated. I tried some different methods, but haven't gotten it to work.

What am I missing?

I figured it out:

Jacobs-MacBook-Pro:bin jacob$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: A .pydistutils.cfg file was found in $HOME, which may cause Python
builds to fail. See:
  https://bugs.python.org/issue6138
  https://bugs.python.org/issue4655
Jacobs-MacBook-Pro:~ jacob$ more .pydistutils.cfg 
[install]
prefix=

I vaguely remember putting that file there sometime in the past to try to use the Google App Engine SDK ( DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both ). I just removed it, and now pip install works fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM