Question: 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: 
First, add all package to `requirements.txt`

```
pip freeze > requirements.txt

```

Then remove all

```
pip uninstall -y -r requirements.txt 

```
I simply wanted to remove packages installed by the project, and not other packages I've installed (things like `neovim`, `mypy` and `pudb` which I use for local dev but are not included in the app requirements). So I did:

`cat requirements.txt| sed 's/=.*//g' | xargs pip uninstall -y`

which worked well for me.