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: 
Other answers that use `pip list` or `pip freeze` **must include `--local`** else it will also uninstall packages that are found in the common namespaces. 

So here are the snippet I regularly use

```
 pip freeze --local | xargs pip uninstall -y

```

Ref: `pip freeze --help`
Best way to remove all packages from the virtual environment, it worked well in windows, but I didn't check in the Linux env.

**Windows:**

```
pip freeze > unins ; pip uninstall -y -r unins ; del unins

```

**Linux:**

```
pip3 freeze > unins ; pip3 uninstall -y -r unins ; rm unins

```