snippetpythonCriticalCanonical
How do I remove all packages installed by pip?
Viewed 0 times
howpippackagesremoveinstalledall
Problem
How do I uninstall all packages installed by pip from my currently activated virtual environment?
Solution
I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtualenv:
In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):
If you have packages installed directly from github/gitlab, those will have
Like:
You can add
pip freeze | xargs pip uninstall -yIn 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 --exclude-editable | xargs pip uninstall -yIf you have packages installed directly from github/gitlab, those will have
@.Like:
django @ git+https://github.com/django.git@You can add
cut -d "@" -f1 to get just the package name that is required to uninstall it.pip freeze | cut -d "@" -f1 | xargs pip uninstall -yCode Snippets
pip freeze | xargs pip uninstall -ypip freeze --exclude-editable | xargs pip uninstall -ypip freeze | cut -d "@" -f1 | xargs pip uninstall -yContext
Stack Overflow Q#11248073, score: 1985
Revisions (0)
No revisions yet.