realpython / python-guide

Python best practices guidebook, written for humans.
https://docs.python-guide.org
Other
28.32k stars 5.83k forks source link

Suggested function for installing packages globally does not work as intended #1099

Closed trk9001 closed 3 years ago

trk9001 commented 3 years ago

In the section on requiring an active virtual environment for pip, a shell function gpip is suggested for the purpose of installing packages globally (when pip is configured to require a virtual environment):

gpip() {
    PIP_REQUIRE_VIRTUALENV="" pip "$@"
}

However, pip's documentation (as of v21.1.1) contains the following note:

Environment variables set to be empty string will not be treated as false. Please use no, false or 0 instead.

This means that when using pip.conf (or pip.ini on Windows) with require-virtualenv = true, the gpip shell function fails to work as intended. I have tested this behaviour with pip-21.1.1 on Fedora 34.