DevOps | Cloud | Analytics | Open Source | Programming





How To Remove all Python packages installed by pip?



This post explains - How To Remove all Python packages installed by pip. To do that lets try the below  

Option 1:


Use below command -


pip freeze | xargs pip uninstall -y

 

Option 2:


If there are any packages which were installed usig VCS,  then we will exclude those . And then will remove the packages


pip freeze | grep -v "^-e" | xargs pip uninstall -y

 

Option 3:


  • Get the list of all Python pip package in the requirements.txt file - Note: This OVERWRITES the Existing requirements.txt else will create new one.

pip freeze > requirements.txt

  • Remove all packages - one by one

pip uninstall -r requirements.txt

  • Remove all packages at once -

pip uninstall -r requirements.txt -y

  Hope This post helps to explain - How To Remove all Python packages installed by pip.   Additional Reads: