【发布时间】:2016-05-05 03:28:54
【问题描述】:
前言:我的 OS X Python 安装一团糟。在发现 Homebrew 之前,我开始使用系统 Python 方式。所以我一直在使用sudo pip install。我现在正在尝试清理所有内容,然后针对 Homebrew 的 Python 安装/链接 pip 包。
1)在许多 SO 答案中,人们建议这样做:pip freeze | xargs sudo pip uninstall -y 这对我不起作用。我得到了很长的追溯。这些是其中最具代表性的部分:
~ $ pip freeze | xargs sudo pip uninstall -y
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The directory '/Users/smaniato/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling altgraph-0.10.2:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 211, in main
[...]
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.py', '/tmp/pip-p8yIlU-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-p8yIlU-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.pyc', '/tmp/pip-p8yIlU-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.pyc',
[...]
"[Errno 1] Operation not permitted: '/tmp/pip-p8yIlU-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph'")]
其中altgraph 只是pip list 中的第一个 pip 包(请记住这一点)。
2) 然后我按照警告的建议尝试了pip freeze | xargs sudo -H pip uninstall -y,但这只是删除了警告。错误消息仍然存在。
3) 我还尝试 chown-ing 任何引起投诉的目录(例如,~/Library/Caches/pip 及其一些父母和子女)。由于某种原因,我不能chown 最有问题的目录,/tmp:
~ $ sudo chown -R ${USER} /tmp
chown: /tmp: Operation not permitted
4) 最后,我尝试从列表的下方手动卸载一个包,瞧,我可以轻松地执行sudo pip uninstall virtualenv 之类的操作。尝试手动卸载 altgraph 会导致上述相同的错误。
任何想法如何进行?记住,我不关心任何一个包;我只想使用 Homebrew 的 Python 核对 pip 并从头开始。谢谢!
更新:
- 手动查看列表,
bdist-mpkg-0.5.0也会发生同样的事情 - 还有一些:
matplotlib、zope.interface、xattr、six、scipy、pytz。
【问题讨论】:
标签: macos python-2.7 pip