Reputation:
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?
Upvotes: 20
Views: 39204
Reputation: 1
installing any package using user command
for upgrading pip :
python -m pip install --upgrade --user pip
Upvotes: 0
Reputation: 42425
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.
Upvotes: 23
Reputation: 2333
According to the pip documentation, that syntax is correct, but requires Python 2.6.
User Installs
With Python 2.6 came the “user scheme” for installation, which means that all Python distributions support an alternative install location that is specific to a user. The default location for each OS is explained in the python documentation for the site.USER_BASE variable. This mode of installation can be turned on by specifying the –user option to pip install.
Moreover, the “user scheme” can be customized by setting the PYTHONUSERBASE environment variable, which updates the value of site.USER_BASE.
To install “SomePackage” into an environment with site.USER_BASE customized to ‘/myappenv’, do the following:
export PYTHONUSERBASE=/myappenv
pip install --user SomePackage
So the following entry should work for you:
export PYTHONUSERBASE=~/.local
pip install --user rpy2
Upvotes: 4