Install a Python package into a different directory using pip?

The –target switch is the thing you’re looking for:

pip install --target=d:\somewhere\other\than\the\default package_name

But you still need to add d:\somewhere\other\than\the\default to PYTHONPATH to actually use them from that location.

-t, –target <dir>
Install packages into <dir>. By default this will not replace existing files/folders in <dir>.
Use –upgrade to replace existing packages in <dir> with new versions.


Upgrade pip if target switch is not available:

On Linux or OS X:

pip install -U pip

On Windows (this works around an issue):

python -m pip install -U pip

Leave a Comment