Introduction

The pip dependency resolver introduced in pip 20.3 enforces strict dependency resolution, which can cause conflicts after upgrading packages. When two or more packages require incompatible versions of a shared dependency, pip raises a ResolutionImpossible error.

This error commonly appears when upgrading packages in an existing project, especially after a major Python version bump or when mixing packages with tight version constraints.

Symptoms

  • pip install fails with "ResolutionImpossible: Could not find a version that satisfies the requirement"
  • Conflicting dependency tree shown after pip reports "ERROR: Cannot install X and Y because these package versions have conflicting dependencies"
  • Virtual environment works until a single package upgrade breaks the entire dependency graph

Common Causes

  • Two packages require mutually exclusive versions of a shared dependency
  • pip version upgraded from legacy resolver to the new backtracking resolver
  • A package pins a dependency too narrowly (e.g., requests==2.28.0 while another needs requests>=2.31.0)

Step-by-Step Fix

  1. 1.Identify the conflicting packages: Run pip with verbose output to see which packages conflict.
  2. 2.```bash
  3. 3.pip install --upgrade problematic-package
  4. 4.# Error output:
  5. 5.# ERROR: Cannot install requests==2.28.0 and urllib3==2.1.0 because these
  6. 6.# package versions have conflicting dependencies.
  7. 7.#
  8. 8.# The conflict is caused by:
  9. 9.# requests 2.28.0 depends on urllib3<1.27 and >=1.21.1
  10. 10.# The user requested urllib3 2.1.0
  11. 11.`
  12. 12.Use pip-tools to generate a compatible lock file: pip-compile resolves all dependencies into a consistent set.
  13. 13.```bash
  14. 14.pip install pip-tools
  15. 15.echo 'requests>=2.28.0' > requirements.in
  16. 16.echo 'urllib3>=2.0.0' >> requirements.in
  17. 17.pip-compile requirements.in
  18. 18.# Produces requirements.txt with resolved versions
  19. 19.pip install -r requirements.txt
  20. 20.`
  21. 21.Relax version constraints in requirements.txt: Replace exact pins with compatible ranges.
  22. 22.`
  23. 23.# BEFORE (causes conflict):
  24. 24.requests==2.28.0
  25. 25.urllib3==2.1.0

# AFTER (allows resolver to find compatible versions): requests>=2.28.0 urllib3>=1.21.1 ```

  1. 1.Force reinstall with --no-deps as last resort: Bypass dependency checking when you know the combination works.
  2. 2.```bash
  3. 3.pip install --no-deps urllib3==2.1.0
  4. 4.# WARNING: Only use this if you have verified compatibility
  5. 5.# through testing. This can cause runtime errors.
  6. 6.`

Prevention

  • Use pip-tools or poetry to manage dependencies with proper constraint resolution
  • Pin dependencies in requirements.txt but use compatible ranges (>=) not exact pins (==)
  • Run pip check regularly to detect broken dependency chains before they cause issues
  • Use a dedicated virtual environment per project to isolate dependency graphs