Forcing an existing module to be installed in a specific path
Question: I have a module already installed in `/usr/lib64/...` by administrator

    
    
    Python 2.7.6 (default, Nov 11 2013, 13:13:15) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import matplotlib
    >>> print matplotlib.__file__
    /usr/lib64/python2.7/site-packages/matplotlib/__init__.pyc
    

What I want to do now is to have it installed in:

`/home/myname/.local/lib/python2.7/site-packages`

But when I tried to install it using this command:

    
    
    $ easy_install-2.7 --install-dir=/home/myname/.local/lib/python2.7/site-packages matplotlib
    

What I get is this:

    
    
    packages matplotlib 
    Searching for matplotlib
    Best match: matplotlib 1.3.1
    Adding matplotlib 1.3.1 to easy-install.pth file
    
    Using /usr/lib64/python2.7/site-packages
    Processing dependencies for matplotlib
    Finished processing dependencies for matplotlib
    

Which means it doesn't get installed at all. I confirmed this with this
snippet again:

    
    
     >>> import matplotlib
     >>> print matplotlib.__file__
    
     or
    
     $ ls -lh /home/myname/.local/lib/python2.7/site-packages
    

How can I get it installed in my desired path and bypassing the already
installed version.


Answer: What you need to do here (_ideally_) is use
[virtualenv](https://pypi.python.org/pypi/virtualenv)

  1. Download [virtualenv](https://pypi.python.org/pypi/virtualenv)
  2. Extract `virtualenv-<version>.tar.gz`
  3. `cd /path/to/virtualenv`
  4. Run: `python virtualenv.py $HOME`

You should then be able tod;

    
    
    pip install matplotlib
    

`which pip` should by something like: `/home/<user>/bin/pip`.

**NB:** You need to also ensure that `$HOME` is in your `$PATH`.

    
    
    export PATH="$HOME/bin:$PATH"
    wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.6.tar.gz#md5=f61cdd983d2c4e6aeabb70b1060d6f49^C
    tar zxvf virtualenv-1.11.6.tar.gz ^Cbash-4.2# cd virtualenv-1.11.6^C
    python virtualenv.py $HOME^C
    
    which pip  # should be $HOME/bin/pip
    
    pip install matplotlib
    

**Also Note:** Do not cusotmize `PYTHONPATH` in any way.
[virtualenv](https://pypi.python.org/pypi/virtualenv) takes care of all the
nitty gritty. ALso you may find
[virtualenvwrapper](https://pypi.python.org/pypi/virtualenvwrapper) a useful
add-on.

