Fix Python – Install a Python package into a different directory using pip?

Question

Asked By – Monika Sulik

I know the obvious answer is to use virtualenv and virtualenvwrapper, but for various reasons I can’t/don’t want to do that.

So how do I modify the command

pip install package_name

to make pip install the package somewhere other than the default site-packages?

Now we will see solution for issue: Install a Python package into a different directory using pip?


Answer

Use:

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

You might also want to use --ignore-installed to force all dependencies to be reinstalled using this new prefix. You can use --install-option to multiple times to add any of the options you can use with python setup.py install (--prefix is probably what you want, but there are a bunch more options you could use).

This question is answered By – Ian Bicking

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0