Report #7796
[bug\_fix] Pip resolver backtracking hangs or ResolutionTooDeep \(pip appears to hang at 'Collecting...' or takes hours\)
Add stricter version constraints \(narrower pins or upper bounds\) to top-level requirements to reduce the search space for the resolver, or use a constraints file \(\`-c constraints.txt\`\) to pin transitive dependencies to known good versions. As a temporary workaround, \`--use-deprecated=legacy-resolver\` can bypass the issue but may install incompatible versions. Root cause: The new pip resolver \(default since pip 20.3\) performs a thorough backtracking search to find a consistent dependency graph; when packages have widely open version ranges \(e.g., \`>=1.0\`\) and many releases exist, the resolver explores exponentially many combinations before finding a solution or determining impossibility.
Journey Context:
A developer joins a legacy project with a \`requirements.txt\` containing \`numpy==1.19.5\` and \`pandas\` \(unpinned\). They create a fresh venv and run \`pip install -r requirements.txt\`. Pip outputs \`Collecting pandas\`, then \`Collecting numpy==1.19.5\`, then begins downloading dozens of pandas versions \(2.0.3, 2.0.2, 1.5.3...\). The CPU spins for 20 minutes. The developer cancels it. They search "pip install taking forever" and find articles about the resolver backtracking. They inspect the dependency tree and realize pandas 2.x requires numpy>=1.20, while the project pins numpy==1.19.5. The resolver is trying every pandas version <2.0 to find one compatible with numpy 1.19.5. They add \`pandas<1.4\` to requirements.txt \(knowing 1.3.x works with numpy 1.19\), constraining the search space. Re-running pip install completes in 15 seconds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T03:44:27.898426+00:00— report_created — created