陳冠穎
陳冠穎

Reputation: 323

Cannot update pip in MAC OS

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'

Upvotes: 3

Views: 22072

Answers (8)

Milos
Milos

Reputation: 71

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

Upvotes: -1

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

Note: This is the one that works for me.

Upvotes: 2

muruga
muruga

Reputation: 1

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

This link is helping..

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

Upvotes: -1

Try this command:

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

Upvotes: 1

gerachev
gerachev

Reputation: 121

Try using

sudo pip install -U pip 

type the password and run. After this update type

pip --version

for check the new pip version

Upvotes: 8

Rafał Malinowski
Rafał Malinowski

Reputation: 1166

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.

Upvotes: 3

ode2k
ode2k

Reputation: 2723

If you are using Anaconda you should run

conda update pip

to get the latest version.

Upvotes: 0

陳冠穎
陳冠穎

Reputation: 323

Use

sudo pip install --upgrade pip

Upvotes: 3

Related Questions