pip: install package into home directory - always 10 Feb 2017
TL;DR
Don’t usesudo pip install <package-name>
like everybody on the internet tells you to. Usepip install --user <package-name>
. To omit--user
, create apip.conf
as outlined below.
We Rubyists generally don’t install packages via sudo
. We’re not crazy enough
to spill things all over the directories managed by the OS’ vendor.
So, while the Python community will spend 3 more years figuring shit
out set the environment variable PIP_USER=y
or create a pip
config file ~/.pip/pip.conf
with the following content:
From now on pip install <package-name>
will always install packages into your
home (that’s ~/Library/Python
on macOS) and you can throw shit away easily.
While this should be enough for the occasional python developer consider using
virtualenv (which is equivalent to bundler’s --path
option) for more complex setups.
And when your OS’s Python version is not enough use pyenv (which is
the equivalent to the Ruby version manager rbenv) to run multiple
Pythons without conflicts.