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?
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?
This is the command that works for me:
I wanted to elevate this answer out of a comment section because it's one of the most elegant solutions in the thread. Full credit for this answer goes to @joeb.
This worked great for me for the use case of clearing my user packages folder outside the context of a virtualenv which many of the above answers don't handle.
Edit: Anyone know how to make this command work in a Makefile?
Bonus: A bash alias
I add this to my bash profile for convenience:
Then run:
Alternative for pipenv
If you happen to be using pipenv you can just run:
On Windows if your
path
is configured correctly, you can use:It should be a similar case for Unix-like systems:
Just a warning that this isn't completely solid as you may run into issues such as 'File not found' but it may work in some cases nonetheless
EDIT: For clarity:
unins
is an arbitrary file which has data written out to it when this command executes:pip freeze > unins
That file that it written in turn is then used to uninstall the aforementioned packages with implied consent/prior approval via
pip uninstall -y -r unins
The file is finally deleted upon completion.
Cross-platform support by using only
pip
:This was the easiest way for me to uninstall all python packages.
Method 1 (with
pip freeze
)Method 2 (with
pip list
)Method 3 (with
virtualenv
)