Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

pip: ResolutionImpossible when two requirements pin the same package

One pin too tight breaks the whole install. Read the chain, pick the side that should move, and make the resolution reproducible with a lock.

~5 min readPython
#Python#pip#Dependency Management#Packaging
Two dependency chains of small package blocks colliding at one shared crate with amber sparks

Introduction & Quick Summary

Symptom. Installing a project's dependencies in one command fails, and pip prints the same wall of text however you phrase the request:

code
ERROR: Cannot install myapp==2.1.0 because these package versions have conflicting dependencies. The conflict is caused by: The user requested pydantic==2.9.2 fastapi 0.112.0 depends on pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 ...

On pip's newer resolver the exception is reported as ResolutionImpossible, often with a chain of The user requested and X depends on lines and no single obvious culprit. Installing packages one at a time succeeds, and then something else breaks.

Cause. A dependency graph with no satisfying assignment: two requirements pin incompatible versions of the same package, or a marker/extra combination makes two branches active for the same environment. pip backtracked, found no combination that satisfies every constraint, and reported the last conflict it hit, which is not necessarily the first one.

Fix. Read the report as constraints, not as instructions, and let a lockfile or a resolver tool do the search:

bash
# 1. what actually requires the conflicting package pip install --dry-run --report - pydantic==2.9.2 2>/dev/null | python3 -m json.tool | head -40 pipdeptree --warn silence | grep -A2 -B2 pydantic
bash
# 2. let a resolver produce a consistent set, then freeze it pip install -U pip pip install "fastapi==0.112.0" "pydantic>=2.9,<3" pip freeze > requirements.lock
toml
# 3. pyproject: keep one source of truth per dependency [project] dependencies = [ "fastapi==0.112.0", "pydantic>=2.9,<3", ]

The rest of this guide is about reading the conflict chain, the four situations that produce it most often, and why the popular workarounds hide the problem instead of solving it.

Core Mechanics, Signatures & Reproducible Setup

pip's resolver collects requirements, picks candidate versions, and backtracks when a choice makes another requirement unsatisfiable. ResolutionImpossible means every branch of that search failed. The report lists the constraints involved, and the useful part is the last two or three lines before the error, because those are the constraints that could not be reconciled.

Reproduce a deterministic conflict with two local packages, so the report is small enough to read:

bash
mkdir -p /tmp/pipc/{a,b} && cd /tmp/pipc cat > a/setup.py <<'EOF' from setuptools import setup setup(name="pkg-a", version="1.0", install_requires=["six==1.15.0"]) EOF cat > b/setup.py <<'EOF' from setuptools import setup setup(name="pkg-b", version="1.0", install_requires=["six==1.16.0"]) EOF python3 -m venv .venv && . .venv/bin/activate pip install -q ./a ./b

pip reports pkg-a 1.0 depends on six==1.15.0 and pkg-b 1.0 depends on six==1.16.0, which is the same structure as any real conflict, only with a single line each.

Useful flags while diagnosing, all of which avoid changing the environment:

bash
pip install --dry-run --report report.json -r requirements.txt pip install --dry-run -v "package" 2>&1 | grep -E "Collecting|Downloading|Would install" python3 -m pip debug --verbose | head -20 # tags, platform, python version
bash
# is a stale constraint file or an extra the cause? pip config list pip install --no-cache-dir -r requirements.txt pip install -r requirements.txt --upgrade-strategy only-if-needed

Key Comparison Table

Conflict shapeExampleFix
direct pin vs dependency rangepydantic==2.9.2 and pydantic>=2.10loosen the direct pin
two transitive ranges with no overlapurllib3<2 and urllib3>=2.2upgrade the older dependent
marker overlapnumpy<2 on py3.9, numpy>=2 for one extrasplit extras, or pin per python version
requires-pythonpackage needs >=3.10, environment is 3.9new environment or older package
constraints file driftconstraints.txt pins an old versionregenerate the constraints
platform-only wheelsno wheel for this platforminstall build tools, or another version
extra activated by a dependentpkg[async] pulls a strict pininstall the extra explicitly
WorkaroundWhat it doesWhy it is not a fix
--no-depsskips dependency resolutionleaves an unsatisfied graph that breaks at runtime
--force-reinstallreinstalls, ignores conflictdoes not change the constraints
older pipchanges resolver behaviournew resolver reports real conflicts
--ignore-installedbypasses the installed setduplicates modules, hides the cause
pinning both sides tighteradds another constraintmakes the conflict permanent

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. The user requested is the line to read first

pip repeats the constraint chain, and the first line is your own requirement while the following lines are what depends on it. If your pin is the tighter side, loosen it; if a dependency's range is the tighter side, upgrade that dependency:

bash
pip index versions pydantic 2>/dev/null | head -3 pip download "fastapi==0.112.0" --no-deps -d /tmp/whl >/dev/null && \ unzip -p /tmp/whl/*.whl '*/METADATA' | grep -i "Requires-Dist.*pydantic"

Reading the metadata of the dependent package answers "what range does it accept" without guessing from the error text.

2. Extras that activate different ranges

An extra can pull in a variant of a dependency with its own pins, and the same top-level package then appears twice in the graph. Removing an unused extra is often the whole fix:

toml
[project] dependencies = [ "sqlalchemy[asyncio]>=2.0.30", "asyncpg>=0.29", ]

If the extra is needed, install the transitively pinned version explicitly so the resolver has one target instead of two ranges.

3. Python version markers

A requirements.txt shared between a 3.9 CI job and a 3.12 laptop can encode contradictory markers. pip evaluates markers for the current interpreter, so the error appears on one machine only:

text
pydantic>=2.10; python_version >= "3.10" pydantic<2; python_version < "3.10"

The conflict is real for an environment where both markers are true, which happens if one line was written with the wrong operator. python -m pip install --dry-run -r requirements.txt on the exact interpreter used in CI is the reliable test.

4. Constraints files that outlive their packages

A constraints.txt generated a year ago pins versions that a new dependency cannot use. The error names your own file only as -c constraints.txt, which is easy to miss:

bash
pip install -r requirements.txt -c constraints.txt --dry-run -v 2>&1 | grep constraints grep -n "pydantic" constraints.txt

Regenerate constraints from a resolved environment instead of maintaining them by hand, or drop them for the dependency that moved.

5. Reproducible resolution with a lock

The lasting fix for a service is a lockfile whose resolution happened once, on purpose. pip-tools and uv both produce one, and CI installs from it rather than re-resolving:

bash
pip install pip-tools pip-compile --generate-hashes -o requirements.lock pyproject.toml pip install --require-hashes -r requirements.lock
bash
# uv, if already in use uv pip compile pyproject.toml -o requirements.lock uv pip sync requirements.lock

A lock turns "resolution impossible" into a build-time event rather than a deploy-time one, and it makes the conflict visible in the pull request that introduced it.

6. When the resolver is right and the requirement is wrong

Sometimes the honest answer is that the two features cannot coexist in one environment. Splitting them into two services, or two optional extras, is a real solution; forcing both with --no-deps postpones a ModuleNotFoundError or an AttributeError to production traffic:

bash
pip install -r requirements-core.txt pip install -r requirements-ml.txt # separate environment, separate image

Common Compilation/Runtime Mistakes & Version Gotchas

  • Reading only the first error line. The conflict chain at the end is the actual evidence.
  • Reaching for --no-deps. It installs an unsatisfiable graph and moves the failure to import time.
  • Upgrading pip to "fix" resolution. Newer pip finds the same conflict and explains it better.
  • Pinning both sides tighter. Two exact pins with no overlap can never resolve.
  • Ignoring requires-python. A package that needs 3.10 cannot install on a 3.9 runner.
  • Sharing one requirements.txt across Python versions without markers. The markers must be correct.
  • Keeping an old constraints file. It pins the past and blocks the present.
  • Resolving on every deploy. A lockfile makes resolution a reviewed event.

When the report is long, extract the constraint lines with the regex tester, and compare the resolved and requested dependency sets with the text diff tool before editing anything.

Reference: pip's dependency resolution, the pip user guide, and the version specifiers specification.

Official references

primary documentation

The Python documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Python work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Python guides

More in Python

All Python guides

The guides filed next to this one in Python, in library order.