pip: Could not find an activated virtualenv (required) pip: Could not find an activated virtualenv (required) python python

pip: Could not find an activated virtualenv (required)


Open your ~/.bashrc file and see if this line is there -

export PIP_REQUIRE_VIRTUALENV=true

It might be causing the trouble. If it's there, change it to false and run -

source ~/.bashrc

If not, run export PIP_REQUIRE_VIRTUALENV=false from terminal.

Note: everything works the same if you have .bash_profile instead of .bashrc in your current user's root directory.


@Bibhas has it; +1 to look for export PIP_REQUIRE_VIRTUALENV=true in ~/.profile or ~/.bashrc. You can confirm the setting in your current shell with env |grep PIP_REQUIRE_VIRTUALENV.

This setting is a good safety check; more often than not, you'll want to be installing things into virtualenvs. However, sometimes you do want to be working with the global/system python. In those cases, take a look at --isolated:

Run pip in an isolated mode, ignoring environment variables and user configuration.

$ pip install --upgrade pipCould not find an activated virtualenv (required).$ pip install --upgrade pip --isolatedRequirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages$ pip freeze --isolated...


An additional solution to those already presented is to add a shell command that will allow you to install py packages by temporarily overriding the default setting. Add this to your ~/.profile, ~/.bashrc or wherever you maintain your shell's exports/settings (in my case, ~/.zshrc).

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

With this simple addition, you can install pip packages to the system via syspip install <package>.