sheeplog

pip: install package into home directory - always

TL;DR
Don’t use sudo pip install <package-name> like everybody on the internet tells you to. Use pip install --user <package-name>. To omit --user, create a pip.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:

[install]
user = true

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.

Further reading

Tagged with tech, python, pip, config

Creative Commons License