blueberryfields blueberryfields - 2 years ago 2209
Python Question

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

I'm trying to fix up one of my virtualenvs - I'd like to reset all of the installed libraries back to the ones that match production.

Is there a quick and easy way to do this with pip?

Answer Source

I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtualenv:

pip freeze | xargs pip uninstall -y

In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):

pip freeze | grep -v "^-e" | xargs pip uninstall -y
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download