Question: I have a pip requirements file that changes during development.

Can `pip` be made to **uninstall** packages that do not appear in the requirements file as well as installing those that do appear? Is there a standard method?

This would allow the pip requirements file to be the canonical list of packages - an 'if and only if' approach.

**Update**: I suggested it as a new feature at <https://github.com/pypa/pip/issues/716>

Answer: 
It's not a feature of `pip`, no. If you really want such a thing, you could write a script to compare the output of `pip freeze` with your `requirements.txt`, but it would likely be more hassle than it's worth.

Using [`virtualenv`](http://www.virtualenv.org/en/latest/), it is easier and more reliable to just create a clean environment and (re)install from `requirements.txt`, like:

```
deactivate
rm -rf venv/
virtualenv venv/
source venv/bin/activate
pip install -r requirements.txt

```
Here's a simple solution that works:

`pip uninstall $(pip freeze) -y`