Cannot perform "sudo pip uninstall" (/ tmp) operation on OS X El Capitan

Preface: My OS X Installing Python is a mess . I started using the Python system before learning about Homebrew. And so I used sudo pip install with forever. Now I am trying to clear everything and then install / link package packages with Python Homebrew.

1) In many SO answers, people suggest doing: pip freeze | xargs sudo pip uninstall -y pip freeze | xargs sudo pip uninstall -y This does not work for me. I get a very long trace. These are the most representative fragments:

 ~ $ 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 -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 the pip list (remember this).

2) Then I tried pip freeze | xargs sudo -H pip uninstall -y pip freeze | xargs sudo -H pip uninstall -y as the warning was suggested, but this will simply remove the warning. Error messages were saved.

3) I also tried using any directories that raised complaints (e.g. ~/Library/Caches/pip and some of his parents and children). For some reason I cannot chown most problematic directory, /tmp :

 ~ $ sudo chown -R ${USER} /tmp chown: /tmp: Operation not permitted 

4) Finally, I tried to manually remove the package from the following list and voila, I could easily do sudo pip uninstall virtualenv , for example. Attempting to manually remove altgraph results in the same error above.

Any ideas on how to proceed? Remember, I do not care about any package; I just want to use nuke pip and start from scratch using Homebrew Python. Thanks!

Update:

  • 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 .
+6
source share
2 answers

I'm sure brew reinstall python somehow fixed a bunch of problems that I had. Then I had to also use nuclear weapons (i.e. rm -rf ) a few things in /usr/local/lib/python2.7/site-packages

The problem and answer related to my specific use case (installing ROS on OS X): https://github.com/mikepurvis/ros-install-osx/issues/11

+9
source

Do not use Homebrew and MacPorts, as well as embedded Python. These are nested solutions that will ultimately fail, one way or another (PEP20: flat is better than nested). At the very least, you have to wait for the package management system to notice any PyPI updates or return to using pip , as you would, without any package manager. Use MacPorts to install only non-Python items that need to be compiled and configured (e.g. ATLAS).

The simplest task is to install stand-alone Python from python.org (either from a binary distribution, or from source from source). No sudo , install under your user. Then:

 pip install -U pip setuptools virtualenvwrapper 

Submit your wrapper from ~/.bashrc to your docs and makevirtualenv foo . All other work will be performed only in virtual environments. If you are using Python 3, then virtualenv is part of the interpreter, so you do not need virtualenvwrapper and the little dance associated with it.

+1
source

All Articles