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: 
The quickest way is to remake the virtualenv completely. I'm assuming you have a requirements.txt file that matches production, if not:

```
# On production:
pip freeze > reqs.txt

# On your machine:
rm $VIRTUALENV_DIRECTORY
mkdir $VIRTUALENV_DIRECTORY
pip install -r reqs.txt

```
In my case, I had accidentally installed a number of packages globally using a Homebrew-installed `pip` on macOS. The easiest way to revert to the default packages was a simple:

```
$ brew reinstall python

```

Or, if you were using `pip3`:

```
$ brew reinstall python3

```