3

I cannot update pip in MAC OS.

I guess the reason maybe I installed PyCharm?!

But I don't know how to fix this problem....

the error message is below:

host-217:~ ChenGuanYing$ pip install -U pip
You are using pip version 7.1.0, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
  Using cached pip-8.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 726, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 314, 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-7.1.0-py2.7.egg/EGG-INFO/dependency_links.txt'
陳冠穎
  • 313
  • 1
  • 5
  • 10
  • Possible duplicate of [Python - PIP install trouble shooting - PermissionError: \[WinError 5\] Access is denied](http://stackoverflow.com/questions/32167418/python-pip-install-trouble-shooting-permissionerror-winerror-5-access-is) – strpeter Jan 25 '17 at 15:29

8 Answers8

8

Try using

sudo pip install -U pip 

type the password and run. After this update type

pip --version

for check the new pip version

Leonardo Alves Machado
  • 2,747
  • 10
  • 38
  • 53
gerachev
  • 121
  • 1
  • 4
3

Use

sudo pip install --upgrade pip
陳冠穎
  • 313
  • 1
  • 5
  • 10
3

I'm guessing you're using El Capitan. The reason you're not able to upgrade pip installed globally with system is SIP - System Integrity Protection. You can disable it but I'm not recommending this.

You'll have problems upgrading other modules installed with xcode/system.

What you can do:

  1. Add $(python -m site --user-base)/bin to your $PATH and then use pip install --user pip no root required for this.
  2. Use brew and install newer version of python. And yes to use brew you still have to modify $PATH to get /usr/local/bin before /usr/bin

And to be honest I'm mixing both of those options. I'm upgrading pip "globally" but it's pip installed with python3.5 from brew. And I'm installing virtualenv with --user flag.

Rafał Malinowski
  • 1,126
  • 1
  • 7
  • 8
2

sudo pip3 install -U pip --ignore-installed pip

Note: This is the one that works for me.

1

Try this command:

sudo pip install -U pip --ignore-installed pip
0

If you are using Anaconda you should run

conda update pip

to get the latest version.

ode2k
  • 2,653
  • 13
  • 20
-1

https://virtualenv.pypa.io/en/stable/installation/#.

This link is helping..

$ pip install --user https://github.com/pypa/virtualenv/tarball/X.X.X

muruga
  • 1
-1

If you are using Python 3.x then Pip3 is installed so command you need to execute to update pip is not pip install --upgrade pip but pip3 install --upgrade pip. To check if everything is installed use python3 -- version and pip3 --version

Milos
  • 71
  • 1
  • 1