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

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


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-envpython -c "import package-name"

How this technique would be useful is beyond this answer.


System: Ubuntu 12.04, Enthought Python Distribution (this is where I wanted to install a new python module)

So the prefix_path environment variable didn't work for me and pip still kept installing it in the default location. But I used How do I change the default directory that pip installs to?

question as a guide. And one of the answers helped me achieve what I needed.

 pip install -d <path_to_my_directory>  

For the path I used: path_to_epd_directory/lib/python2.7/site-packages

This puts the tar.gz file into the site-packages

Then extract it using:

tar -zxvf pymodule.tar.gz

a directory named pymodule is created, cd into that module and type:

 python setup.py install

and that should do the job.


You can use this code to install you package to a specific path.

pip install [package name] --target /path/to