Skip to content

Instantly share code, notes, and snippets.

@cpl
Created September 11, 2017 04:54
Show Gist options
  • Save cpl/fb6bd9a3b617efc1b7c03178a987fea1 to your computer and use it in GitHub Desktop.
Save cpl/fb6bd9a3b617efc1b7c03178a987fea1 to your computer and use it in GitHub Desktop.
A script that uninstalls any Python package given by `pip freeze` (or any other list)

How to use

  1. Download the pip_uninstall_all.py file
  2. Run pip freeze | python pip_uninstall_all.py

You can also use a text files with the packages you wish to uninstall and provide em using stdin

#!/usr/bin/python
import sys
import os
packages = sys.stdin.readlines()
for package in packages:
package = package.strip().split('==')[0]
os.system('pip uninstall -y %s' % package)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment