How to prevent accidentally calling pip when I am not in a virtualenv?
I wrote the following script called pip
and added it to my ~/bin
(whi
export PIP_REQUIRE_VIRTUALENV=true
I'd recommend putting this in your ~/.bashrc
file:
export PIP_REQUIRE_VIRTUALENV=true
and you can also add the following function to your ~/.bashrc
that allows you to explicitly call pip outside of a virtual environment if you so choose:
gpip() {
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
Now you can still use your global pip version for doing things like upgrading virtualenv:
gpip install --upgrade pip virtualenv