Check if venv satisfies requirements

How to check if a virtual environment satisfies a requirements.txt?

For old venv I want to quickly check if they have deviated from requirements.txt either due to installing some extra modules to test something or installing other versions of the modules in the requirements, that don’t satisfy the constrains in it.

I could compare on my own the output of pip freeze and requirements.txt, but maybe there is a way for pip or some other tool to do it.

You can use the --dry-run flag with pip:

pip install --dry-run -r requirements.txt

If the requirements are already satisfied, it gives that message, otherwise a “Would install” message with list of packages.

1 Like