I use a different virtual environment for every project I work on (using pyenv
and pyenv-virtualenv
), and I often come across a message like then when installing a python package using pip
:
WARNING: You are using pip version 21.1.3; however, version 21.2.4 is available. You should consider upgrading via the '/Users/.../.pyenv/versions/3.9.6/envs/sdge/bin/python -m pip install --upgrade pip' command.
However, when I run the pip install --upgrade pip
command, it only upgrades pip in that particular virtual environment (which is expected, and that is behavior that I want), and it is annoying to see this across all my different virtual environments.
Is there some kind of shortcut (either with pyenv
, pip
, or the shell) that I could use to run pip install --upgrade pip
on every virtual environment?
I don't use pyenv
so I created this code after reading documentation and source code (not tested):
for env in $(pyenv virtualenvs --bare --skip-aliases); do
pyenv activate $env
pip install --upgrade pip
pyenv deactivate
done