pypa/pip · error · NetworkConnectionError

{resp.status_code} Client Error: {reason} for url: {resp.url

Error message

{resp.status_code} Client Error: {reason} for url: {resp.url}

What it means

Error "{resp.status_code} Client Error: {reason} for url: {resp.url}" thrown in pypa/pip.

Source

Thrown at src/pip/_internal/network/utils.py:71

        try:
            reason = resp.reason.decode("utf-8")
        except UnicodeDecodeError:
            reason = resp.reason.decode("iso-8859-1")
    else:
        reason = resp.reason

    if 400 <= resp.status_code < 500:
        http_error_msg = (
            f"{resp.status_code} Client Error: {reason} for url: {resp.url}"
        )

    elif 500 <= resp.status_code < 600:
        http_error_msg = (
            f"{resp.status_code} Server Error: {reason} for url: {resp.url}"
        )

    if http_error_msg:
        raise NetworkConnectionError(http_error_msg, response=resp)


def response_chunks(
    response: Response, chunk_size: int = DOWNLOAD_CHUNK_SIZE
) -> Generator[bytes, None, None]:
    """Given a requests Response, provide the data chunks."""
    try:
        # Special case for urllib3.
        for chunk in response.raw.stream(
            chunk_size,
            # We use decode_content=False here because we don't
            # want urllib3 to mess with the raw bytes we get
            # from the server. If we decompress inside of
            # urllib3 then we cannot verify the checksum
            # because the checksum will be of the compressed
            # file. This breakage will only occur if the
            # server adds a Content-Encoding header, which
            # depends on how the server was configured:

View on GitHub (pinned to d7d0d0a394)

When it happens

Trigger: Thrown at src/pip/_internal/network/utils.py:71 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/81dd61747503ec39.json. Report an issue: GitHub.