OSX: Python anaconda error when installing pip

The problem

When you try to install pip with conda:

conda install pip 

you get the following erorr:

CondaOSError: OS error: failed to link (src=u'/Users/username/anaconda/pkgs/pip-9.0.1-py27_0/lib/python2.7/site-packages/pip/__init__.py', dst='/Users/zdong/anaconda/lib/python2.7/site-packages/pip/__init__.py', type=1, error=OSError(17, 'File exists'))`

The solution

THe error is common when someone installed pip as root, try to delete the pip package from your anaconda packages:

sudo rm -rf /Users/username/anaconda/lib/python2.7/site-packages/pip

Remember to change the path to match your username!

Solution 2

If the problem persists, try to install pip with --force:

conda install pip --force