pip won't install Python packages locally with --user

user248237 picture user248237 · Mar 14, 2013 · Viewed 25.8k times · Source

I'm trying to install packages locally with pip. It used to work with --user but now when I try it, it finds the version of the package in /usr/local/lib/ and then does not install it locally. Normally it would install things in ~/.local but now it just checks the system-wide dir for the package and if it's there, it does not install it (which is not what I want) and if it's not there, it tries to install it in /usr/local/lib which I do not have write permissions at. Eg:

$ pip install --user rpy2
Requirement already satisfied (use --upgrade to upgrade): rpy2 in /usr/local/lib/python2.7/dist-packages/

How can I make pip install --user always go to ~/.local and not a system-wide directory?

Answer

Piotr Dobrogost picture Piotr Dobrogost · Nov 30, 2013

Citing Marcus Smith (maintainer of pip):

If you think the global site is out of date, and want the latest in the user site, then use:
pip install --upgrade --user SomePackage

If the global site is up to date, and you really just want the same thing duplicated in --user, then use:
pip install --ignore-installed --user SomePackage (which works correctly now after the merge of #1352, which is to be released in v1.5)

How can I make pip install --user always go to ~/.local and not a system-wide directory?

Use both --upgrade and --ignore-installed arguments.