← Back to TIL

Debugging pip's backtracking output

Pip's backtracking feature is a way for it to try out older and older versions of a package when resolution fails. In theory this should lead to better resolution outcomes, and often it does, but there can be cases where it reaches a sort of deadlock and locks up for hours trying a multitude of combinations of versions with no resolution. In these situations it can be useful to see exactly what is causing the resolution candidates to be rejected. Pip doesn't surface this information by default, and there isn't even a documented way to see it. Digging through pip's source code though, there is a very handy env var hidden away

PIP_RESOLVER_DEBUG=1 pip install

Setting this provides extremely verbose logs but if you dig into them it can be very helpful to see exactly what is causing the dependency resolution problems.