Regis' Blog

L'informatique, L'amour, Les vaches

Remove all Python packages installed with PIP
January 01, 2017
in Python |
Share this post
| |
Remove all Python packages installed with PIP

PIP is a great package manager. Pearhaps not the greatest manager but it does the job quite well. For a Python programmer, it's the only way to install PIP allow to install, upgrade and uninstall packages. But sometime we need to remove all packages, for example for a installer script.

For that, PIP has an option that allow to process an uninstallation without confirmations: --yes. So if you ask all packages and then execute line by line the uninstaller, you'll removee all. For that we'll use the xargs command. It allow to use a \n as separator (see man xargs)

Just type in a shell :

pip freeze | xargs pip uninstall -y

And all your PIP packages will be removed.

Magic.

January 01, 2017
in Python |
Share this post
| |