Question: pip install through requirements.txt vs individual calls to pip install package-name

A general question about how pip install works.

It shouldn’t be too important, but to give some context, the question relates to some work I’m involved with at arms-length to add support to Bazel for thirdparty Python dependencies. See: Fetch pip packages incrementally · Issue #395 · bazelbuild/rules_python · GitHub

Given a requirements.txt with the contents:


Is there a difference in the behaviour of pip for the following commands:

  1. pip install -r requirements.txt
  2. pip install package-a==0.0.1 package-b==0.0.1
  3. pip install package-a==0.0.1 && pip install package-b==0.0.1

My understanding is that 1 and 2 are equivalent?

1, 2 and 3 will only be equivalent if the requirements.txt contains the full transitive closure of dependencies? If package-a and package-b both depend on some unlisted package-c, then the packages that may be installed may differ for 3.

Your understanding is correct. More specifically, 3 may produce a different result from 1 and 2 if any of a transitive dependency of package-a is not compatible with package-b.


Thanks so much for the quick response.