What is the easiest way to remove all packages installed by pip?

Question:

I want to revert my Python install back to its base state so I can start using virtualenv. Is there an easy way to uninstall only those packages that have been installed after Python was set up?

Asked By: Cam

||

Answers:

The following command should do the trick:

pip freeze > requirements.txt && pip uninstall -r requirements.txt -y

Alternatively you can skip the creation of any intermediate files (i.e. requirements.txt):

pip uninstall -y -r <(pip freeze)
Answered By: Giorgos Myrianthous

do following

  1. store all the pip packages in requirements.txt

    python -m pip freeze > requirements.txt
    
  2. remove all pip packages which menetioned in requirements.txt

    python -m pip uninstall -r requirements.txt
    
Answered By: sahasrara62
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.