title: How to ensure that the state of the venv equals the one declared in requirements.txt?
body: <p>In Python, the <code>requirements.txt</code> file declares a set of concrete dependencies of a python application.</p>
  
  <p>Often, during development, dependencies change. When the set of new dependencies overlaps with the set of old dependencies, all is good, as a <code>venv/bin/pip install -r requirements.txt</code> updates them accordingly.</p>
  
  <p>However, when the set of new dependencies is smaller than the set of old dependencies, old dependencies become "dangling" as they are no longer used, but still populate the <code>pip freeze</code>.</p>
  
  <p>Is there any command to force pip to ensure that <code>pip freeze</code> after a <code>pip install -r requirements.txt</code> is the same as declared in the <code>requirements.txt</code>?</p>
  
  <p>My current solution is to delete the venv and create a new one, which is mildly time-consuming.</p>
  
  <p>Note that the goal is not to generate a <code>requirements.txt</code> file, is to make venv map to a given requirements file.</p>