Pip install python package into a specific directory other than the default install location

user2502020 picture user2502020 · Jun 20, 2013 · Viewed 58.3k times · Source

The default location where pip installes packages on my Ubuntu system is '/usr/local/lib/pytho2.7/dist-packages/' which I think is the default in general. I am using Enthought python distribution (EPD not canopy) and would like to install a package into EPD as I usually work with the python from the EPD distribution on my system. I would like to know into which directory inside EPD the new files need to be installed using pip ; as the directory structure for EPD on linux seems to be quite different from the EPD directory structure on MAC OS for where there seem to be many examples.

Also I have come across this :

pip install --install-option="--prefix=$PREFIX_PATH" package_name

as the accepted answer to a question similar to this. I would like to know what the purpose of the $PREFIX_PATH environment variable is as mine is currently blank. And what path I need to specify on Ubuntu for my Enthought EPD distribution to install python modules.

I apologize for the relatively naive question but I am quite new to EPD on ubuntu and am still trying to figure it out.

Answer

RayLuo picture RayLuo · May 2, 2014

This line should work for everyone, as mentioned in the documentation.

pip install package_name -t any/path/i/like

PS:

And to address the comment of @CPiLL, the any/path/i/like can really be anything, such as /tmp/my-test-env. The package being installed in this way will NOT be available for your usual python environment, in fact they will NOT even show up using pip list. And python -c "import package_name" will generally FAIL with ImportError exception, unless you cd into that folder first:

cd /tmp/my-test-env
python -c "import package-name"

How this technique would be useful is beyond this answer.