Preface: My OS X Python installation is a mess. I started using the system Python way before I found out about Homebrew. And so I've been using sudo pip install
since forever. I'm now trying to clean everything up and then install/link pip packages against Homebrew's Python.
1) In many SO answers, people suggest doing: pip freeze | xargs sudo pip uninstall -y
That doesn't work for me. I get a very long traceback. These are the most representative chunks of it:
~ $ 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'")]
where altgraph
is just the first pip package in pip list
(keep that in mind).
2) I then tried pip freeze | xargs sudo -H pip uninstall -y
, as the warning suggested, but that simply remove the warning. The error messages persisted.
3) I also tried chown-ing any directories that raised complaints (e.g., ~/Library/Caches/pip
and some of its parents and children). For some reason, I cannot chown
the most problematic directory, /tmp
:
~ $ sudo chown -R ${USER} /tmp
chown: /tmp: Operation not permitted
4) Finally, I tried manually uninstalling a package from further down the list and voila, I could easily do sudo pip uninstall virtualenv
for example. Attempting to manually uninstall altgraph
results in the same error above.
Any ideas how to proceed? Remember, I don't care about any one package; I just want to nuke pip and start from scratch using Homebrew's Python. Thanks!
Updates:
- Going down the list manually, the same thing happens with
bdist-mpkg-0.5.0
- A few more:
matplotlib
,zope.interface
,xattr
,six
,scipy
,pytz
.