Python 在macOS Sierra上安装pip
我一直试图通过brew在macOS sierra上安装pip,但每次安装完成时,都没有在Python 在macOS Sierra上安装pip,python,macos,pip,macos-sierra,Python,Macos,Pip,Macos Sierra,我一直试图通过brew在macOS sierra上安装pip,但每次安装完成时,都没有在/usr/local/ceral/python/2.7.13/bin中安装二进制文件 我试过: MacBook-Pro ➜ brew reinstall python 然后: 我找到了python的路径,它是/usr/local/ceral/python/2.7.13/bin,但是那里没有用于pip的二进制文件 我还尝试了easy\u install方法: MacBook-Pro ➜ sudo easy_i
/usr/local/ceral/python/2.7.13/bin
中安装二进制文件
我试过:
MacBook-Pro ➜ brew reinstall python
然后:
我找到了python的路径,它是/usr/local/ceral/python/2.7.13/bin
,但是那里没有用于pip的二进制文件
我还尝试了easy\u install
方法:
MacBook-Pro ➜ sudo easy_install pip
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 11, in <module>
load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 352, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2307, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2021, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
brew安装一定有问题 最新的macOS版本
~/ brew reinstall python
==> Reinstalling python
==> Downloading https://homebrew.bintray.com/bottles/python-2.7.13.sierra.bottle.tar.gz
Already downloaded: ~/Library/Caches/Homebrew/python-2.7.13.sierra.bottle.tar.gz
==> Pouring python-2.7.13.sierra.bottle.tar.gz
==> Using the sandbox
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7
==> 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
The error message has the answer for you...
Remove /Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/
and run brew reinstall python
. setuptools
is the wrong version.You just need to install pip
which is not automatically installed in macOS Sierra.
Run sudo easy_install pip
I had this issue and I found this to be the solution. BTW pip isn't installed via brew. It comes with python and python virtualenvs.
if you type which python
without brew install python
you'll get the location in /usr/bin/python
. That is the system python which we don't want to develop with.
So i took the following steps.
1) brew install python
2) export PATH="/usr/local/opt/python/libexec/bin:$PATH"
place that in your ~/.bash_profile
3) source ~/.bash_profile
in your terminal
4) type which python
and that should have changed the location to /usr/local/opt/python/libexec/bin/python
.
This will allow you to pip install normally and use the brew version of python.
Now before high sierra python used to be located in /usr/local/bin
but for some reason if you place /usr/local/bin
in your paths it automatically points back to /usr/bin
, so this is the only solution I have been able to come up with.
Python3 does not have this issue, if you brew install python3
and type which python3
you'll see that it's located in /usr/local/bin/python3
. 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
...
~/brew重新安装python
=>重新安装python
==>下载https://homebrew.bintray.com/bottles/python-2.7.13.sierra.bottle.tar.gz
已下载:~/Library/Caches/Homebrew/python-2.7.13.sierra.battle.tar.gz
==>python-2.7.13.sierra.bottle.tar.gz
==>使用沙箱
==>/usr/local/ceral/python/2.7.13/bin/python-s setup.py--无用户cfg安装--强制--详细--外部管理的单一版本--记录=installed.txt--安装脚本=/usr/local/ceral/python/2.7
==>/usr/local/ceral/python/2.7.13/bin/python-s setup.py--无用户cfg安装--强制--详细--外部管理的单一版本--记录=installed.txt--安装脚本=/usr/local/ceral/python/2.7
==>/usr/local/ceral/python/2.7.13/bin/python-s setup.py--无用户cfg安装--强制--详细--外部管理的单一版本--记录=installed.txt--安装脚本=/usr/local/ceral/python/2.7
==>注意事项
已安装Pip和setuptools。更新它们
pip安装--升级pip安装工具
您可以使用安装Python包
pip安装
它们将安装到站点包目录中
/usr/local/lib/python2.7/site-packages
见:https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md
.已安装应用程序包。
运行“brew linkapps python”将这些应用程序符号链接到/应用程序。
==>摘要
错误消息为您提供了答案
删除/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/
并运行brew重新安装python
setuptools
是错误的版本。您只需安装在macOS Sierra中不会自动安装的pip
运行sudo easy\u install pip
我遇到了这个问题,我发现这就是解决方案。顺便说一句,未通过brew安装pip。它附带python和python virtualenvs
如果键入which python
而不键入brew install python
,您将在/usr/bin/python
中找到位置。这就是我们不想使用的python系统
所以我采取了以下步骤。
1) brew安装python
2) export PATH=“/usr/local/opt/python/libexec/bin:$PATH”
将其放在~/.bash\u配置文件中
3) source~/.bash\u配置文件
在终端中
4) 键入whichpython
,它应该将位置更改为/usr/local/opt/python/libexec/bin/python
这将允许您正常pip安装并使用brew版本的python
在high sierra python之前,它通常位于/usr/local/bin
中,但由于某种原因,如果您将/usr/local/bin
放在路径中,它会自动指向/usr/bin
,因此这是我能够想到的唯一解决方案
Python3没有这个问题,如果您brew安装Python3
并键入哪个Python3
,您将看到它位于/usr/local/bin/Python3
中 值得一提的是,升级到high sierra后,我发现我的机器几乎无法用于开发,甚至多次崩溃
关于python,我在site packages文件夹中有一个权限问题,因此重新安装失败:
$ sudo rm -rf /usr/local/lib/python2.7/site-packages
为了修复它,我完全删除了站点包:
$ 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
有了这个,重新安装python2,并再次拥有一个正常工作的pip2,效果非常好:
curl https://bootstrap.pypa.io/get-pip.py | sudo python
希望这能有所帮助。好的,伙计们,这些答案中有很多是有用的,但没有一个能让我到达终点线。我跑得很高,10.13.4。如上所述的问题是Brew在/usr/local/bin
目录中安装pip,而Python在/usr/bin
目录中(尽管正如Carl所说,Python3正确地转到/usr/local/bin
)
我的即时用例与安装软件包有关
我采取的步骤如下:
清除brew缓存$rm-rf~/Library/Caches/Homebrew
清除站点包$sudo rm-rf/usr/local/lib/python2.7/站点包
重新安装Python$brew重新安装Python
这将下拉Python-3.5.6.high_sierra
并将其放入/usr/local/bin/python3
但是哪个python
仍然显示/usr/bin/python
解决方案是运行brew安装python@2
哪个下拉python@2-2.7.14_3.high_sierra
现在哪个python
显示了正确的路径/usr/local/bin/python
,这也是安装所有pip的地方,所以现在pip可以工作了
当然,如果您还没有安装最新版本的pip,您也应该使用sudo-pip-install——升级pip
对于Mac OS Sierra,无法通过easy\u install
安装pip,因为TLS版本存在问题,安装的开放SSL版本不支持TLS 1.2
因此,使用curl安装pip,如下所示
sudo easy\u install
没有将pip放入brew目录是否存在pip2
存在?@cricket\u 007没有pip
或pip2
在/usr/local/cillar/python/2.7.13/bin
中。好的,当我运行brew postinstall python
时,我遇到了错误。请参阅原始问题以获取更新。不确定为什么需要运行它,但它对我来说很好。尝试删除~/Library/Caches/Homebrew
中的缓存文件
$ 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
curl https://bootstrap.pypa.io/get-pip.py | sudo python