Introduction

When installing multiple packages with pip, the resolver may fail with ResolutionImpossible when two or more packages require incompatible versions of a shared dependency. This commonly happens in projects with large requirements files where package A needs requests>=2.28 while package B pins requests<2.25.

Symptoms

  • pip install -r requirements.txt exits with:
  • `
  • ERROR: Cannot install -r requirements.txt (line 14) and -r requirements.txt (line 23)
  • because these package versions have conflicting dependencies.

The conflict is caused by: package-a 1.2.0 depends on requests>=2.28.0 package-b 3.1.0 depends on requests<2.25.0 `` - ERROR: ResolutionImpossible: If you want to proceed, try --no-deps` - Partial installations leave your environment in an inconsistent state

Common Causes

  • Transitive dependencies pulling in conflicting version ranges
  • One package pinning an exact version while another requires a range
  • Upgrading one package without checking its transitive dependencies
  • Mixing conda and pip packages in the same environment
  • Using outdated packages with old pinned dependencies

Step-by-Step Fix

  1. 1.Identify the conflict chain:
  2. 2.```bash
  3. 3.pip install -r requirements.txt 2>&1 | grep "conflict is caused"
  4. 4.pipdeptree --reverse --packages requests
  5. 5.`
  6. 6.Check which packages need the conflicting dependency:
  7. 7.```bash
  8. 8.pip install pipdeptree
  9. 9.pipdeptree -p requests
  10. 10.`
  11. 11.Upgrade the package with the stricter pin:
  12. 12.```bash
  13. 13.pip install package-b --upgrade
  14. 14.# Often the older package has the outdated pin
  15. 15.`
  16. 16.Use a constraints file to force a compatible version:
  17. 17.```bash
  18. 18.# constraints.txt
  19. 19.requests>=2.28.0,<3.0.0

pip install -r requirements.txt -c constraints.txt ```

  1. 1.If upgrading is not possible, use pip's legacy resolver (not recommended):
  2. 2.```bash
  3. 3.pip install --use-deprecated=legacy-resolver -r requirements.txt
  4. 4.`
  5. 5.This bypasses conflict detection and may produce a broken environment.
  6. 6.Create a compatible requirements set:
  7. 7.```bash
  8. 8.pip-compile requirements.in --generate-hashes
  9. 9.pip install -r requirements.txt
  10. 10.`
  11. 11.Using pip-tools generates a fully resolved, conflict-free set.

Prevention

  • Use pip-tools or uv for deterministic dependency resolution
  • Pin versions with ranges (>=2.28,<3.0) instead of exact pins
  • Run pip check after installations to verify consistency
  • Lock dependencies with pip freeze > requirements.txt after verifying
  • Use uv pip compile for faster resolution with the same compatibility guarantees
  • Review dependency changes before upgrading major packages