如何在 Mac 上安装 pip?
How do I install pip on Mac?
我想不出在 Mac 上设置 pip 的正确方法。我在 Homebrew 上安装了 python@2。当我尝试安装 virtualenv 时,出现此错误:
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.
这里有一些可能有用的额外诊断信息。
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
网络上有很多关于如何设置的意见。其中一些是旧的,比如使用 easy_install
,这似乎已被弃用。我尝试了一些不同的方法,但还没有成功。
我错过了什么?
我想通了:
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=
我依稀记得过去某个时候将该文件放在那里以尝试使用 Google App Engine SDK (DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both)。我刚刚删除了它,现在 pip install
工作正常!
我想不出在 Mac 上设置 pip 的正确方法。我在 Homebrew 上安装了 python@2。当我尝试安装 virtualenv 时,出现此错误:
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.
这里有一些可能有用的额外诊断信息。
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
网络上有很多关于如何设置的意见。其中一些是旧的,比如使用 easy_install
,这似乎已被弃用。我尝试了一些不同的方法,但还没有成功。
我错过了什么?
我想通了:
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=
我依稀记得过去某个时候将该文件放在那里以尝试使用 Google App Engine SDK (DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both)。我刚刚删除了它,现在 pip install
工作正常!