Coder Perfect

Folding $HOME after installing pip packages


Is that even possible? When installing pip, install the python packages inside my $HOME folder. (for example, I want to install mercurial, using pip, but inside $HOME instead of /usr/local)

I’m with a mac machine and just thought about this possibility, instead of “polluting” my /usr/local, I would use my $HOME instead.

This is what PEP370 is all about. Is it enough to simply create a /.local and run pip install package to have these packages installed only in my $HOME folder?

Asked by Somebody still uses you MS-DOS

Solution #1

You don’t have to utilize a virtualenv if you don’t want to. Passing the PEP370 —user parameter to the script is the key. With the latest version of pip, one way to do it is:

pip install --user mercurial

The hg script should be installed in $HOME/.local/bin/hg, and the remainder of the hg package should be installed in $HOME/.local/lib/pythonx.y/site-packages/.

It’s worth noting that the above is correct for Python 2.6. There has been some debate among the Python core developers over the proper directory location for PEP370-style user installations on Mac OS X. On Mac OS X, the location of Python 2.7 and 3.2 was changed from $HOME/.local to $HOME/Library/Python. This could change in a later version. For now, the above locations will be $HOME/Library/Python/x.y/bin/hg and $HOME/Library/Python/x.y/lib/python/site-packages on Python 2.7 (and 3.2 if hg were available on Python 3).

Answered by Ned Deily

Solution #2

At your HOME directory, I would use virtualenv.

$ sudo easy_install -U virtualenv
$ cd ~
$ virtualenv .
$ bin/pip ...

You could then add /bin to your PATH in /.(login|profile|bash profile), whatever is appropriate for your shell, and pip|python|easy install would be utilized by default.

Answered by Ross Patterson

Solution #3

The -t option (—target) can be used to define the destination directory. For further information, see pip install —help. You’ll need to use the following command:

pip install -t path_to_your_home package-name

For instance, in order to install mxnet in my $HOME directory, I type:

pip install -t /home/foivos/ mxnet

Answered by Foivos

Solution #4


It is possible to install pip packages to $HOME rather than /usr/local/lib/, however this is not recommended.

mkdir ˜/.local # then
pip install package 

is not enough.

You need

pip install package --user

as well as the packages are installed


Answered by Timo

Post is based on