Pip: Can't upgrade pip

Created on 30 Apr 2016  路  4Comments  路  Source: pypa/pip

  • Pip version: 6.1.1
  • Python version 2.7.10
  • Operating System: 10.11.4

    Description:

I'm trying to upgrade pip.

I run "pip install --upgrade pip"

Collecting pip
  Using cached pip-8.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 6.1.1
    Uninstalling pip-6.1.1:
      Exception:
      Traceback (most recent call last):
        File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
          status = self.run(options, args)
        File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/install.py", line 352, in run
          root=options.root_path,
        File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 687, in install
          requirement.uninstall(auto_confirm=True)
        File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 730, in uninstall
          paths_to_remove.remove(auto_confirm)
        File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
          renames(path, new_path)
        File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/utils/__init__.py", line 292, in renames
          shutil.move(old, new)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move
          rmtree(src)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
          rmtree(fullname, ignore_errors, onerror)
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
          onerror(os.remove, fullname, sys.exc_info())
        File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
          os.remove(fullname)
      OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/EGG-INFO/dependency_links.txt'
auto-locked

Most helpful comment

OS X doesn't allow upgrading the packages in their own system python, for reasons explained above. Unfortunately there is really little we can do about this.

  • Use a different python distribution, from python.org, Anaconda, homebrew
  • Use a virtualenv
  • Always install with pip install --user

Are the main workarounds.

All 4 comments

try

sudo pip install --upgrade pip

It worked! But when I try and upgrade a package Ansible i still get

 sudo pip install ansible --upgrade
The directory '/Users/justinchristensen66/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.
The directory '/Users/justinchristensen66/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ansible
  Downloading ansible-2.0.2.0.tar.gz (1.5MB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 1.5MB 574kB/s
Collecting paramiko (from ansible)
  Downloading paramiko-2.0.0-py2.py3-none-any.whl (170kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 174kB 3.4MB/s
Requirement already up-to-date: jinja2 in /Library/Python/2.7/site-packages (from ansible)
Requirement already up-to-date: PyYAML in /Library/Python/2.7/site-packages (from ansible)
Collecting setuptools (from ansible)
  Downloading setuptools-20.10.1-py2.py3-none-any.whl (509kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 512kB 1.4MB/s
Requirement already up-to-date: pycrypto>=2.6 in /Library/Python/2.7/site-packages (from ansible)
Requirement already up-to-date: pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko->ansible)
Collecting cryptography>=1.1 (from paramiko->ansible)
  Downloading cryptography-1.3.1-cp27-cp27m-macosx_10_10_intel.whl (2.4MB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 2.4MB 364kB/s
Requirement already up-to-date: MarkupSafe in /Library/Python/2.7/site-packages (from jinja2->ansible)
Collecting enum34 (from cryptography>=1.1->paramiko->ansible)
  Downloading enum34-1.1.4-py2.py3-none-any.whl (61kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 61kB 5.2MB/s
Collecting ipaddress (from cryptography>=1.1->paramiko->ansible)
  Downloading ipaddress-1.0.16-py27-none-any.whl
Collecting six>=1.4.1 (from cryptography>=1.1->paramiko->ansible)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting idna>=2.0 (from cryptography>=1.1->paramiko->ansible)
  Downloading idna-2.1-py2.py3-none-any.whl (54kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 61kB 5.0MB/s
Collecting cffi>=1.4.1 (from cryptography>=1.1->paramiko->ansible)
  Downloading cffi-1.6.0-cp27-cp27m-macosx_10_10_intel.whl (211kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 215kB 3.4MB/s
Collecting pycparser (from cffi>=1.4.1->cryptography>=1.1->paramiko->ansible)
  Downloading pycparser-2.14.tar.gz (223kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 225kB 3.5MB/s
Installing collected packages: setuptools, enum34, ipaddress, six, idna, pycparser, cffi, cryptography, paramiko, ansible
  Found existing installation: setuptools 1.1.6
    Uninstalling setuptools-1.1.6:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 726, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 746, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
    copytree(src, real_dst, symlinks=True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/tmp/pip-_a2DsH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]

On OS X El Capitan, there is a feature turned on by default called "System Integrity Protection". Long story short, it means that nobody, not even root (sudo) can write to certain directories, including /System. You seem to be running into that: setuptools 1.1.6 is the version shipped by Apple, and you're trying to uninstall/upgrade it:

$ /usr/bin/python -c 'import setuptools; print setuptools, setuptools.__version__'
<module 'setuptools' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/__init__.pyc'> 1.1.6

I highly recommend using a virtual environment (virtualenv) instead of trying to install packages with the system python. Alternatively, pip's --user flag may help (but I haven't tested that and never use it myself, instead using a virtualenv).

The alternative is to disable System Integrity Protection, but that's not usually recommended.

OS X doesn't allow upgrading the packages in their own system python, for reasons explained above. Unfortunately there is really little we can do about this.

  • Use a different python distribution, from python.org, Anaconda, homebrew
  • Use a virtualenv
  • Always install with pip install --user

Are the main workarounds.

Was this page helpful?
0 / 5 - 0 ratings