langchain-ai/langchain · error · ValueError

Expected {package} version to be > {gt_version}. Received {i

Error message

Expected {package} version to be > {gt_version}. Received {imported_version}.

What it means

Raised by `check_package_version` in `langchain_core.utils.utils` for the strict lower bound: the installed `package` version is less than or equal to `gt_version` when the caller required strictly greater. Integrations use it to refuse old dependency versions missing features they rely on. The message contrasts the required minimum with the imported version.

Source

Thrown at libs/core/langchain_core/utils/utils.py:184

    imported_version = parse(version(package))
    if lt_version is not None and imported_version >= parse(lt_version):
        msg = (
            f"Expected {package} version to be < {lt_version}. Received "
            f"{imported_version}."
        )
        raise ValueError(msg)
    if lte_version is not None and imported_version > parse(lte_version):
        msg = (
            f"Expected {package} version to be <= {lte_version}. Received "
            f"{imported_version}."
        )
        raise ValueError(msg)
    if gt_version is not None and imported_version <= parse(gt_version):
        msg = (
            f"Expected {package} version to be > {gt_version}. Received "
            f"{imported_version}."
        )
        raise ValueError(msg)
    if gte_version is not None and imported_version < parse(gte_version):
        msg = (
            f"Expected {package} version to be >= {gte_version}. Received "
            f"{imported_version}."
        )
        raise ValueError(msg)


def get_pydantic_field_names(pydantic_cls: Any) -> set[str]:
    """Get field names, including aliases, for a pydantic class.

    Args:
        pydantic_cls: Pydantic class.

    Returns:
        Field names.
    """
    all_required_field_names = set()

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Upgrade the package past the boundary in the message: `pip install -U "pkg>X"` (use the exact minimum stated).
  2. Better: upgrade via the integration's own requirements (`pip install -U langchain-<partner>`) so compatible bounds resolve together.
  3. Rebuild cached Docker/CI images after upgrading; verify with `python -c "import pkg; print(pkg.__version__)"`.

Example fix

# before
# ValueError: Expected pydantic version to be > 1.10.13. Received 1.10.8.

# after (terminal)
# pip install "pydantic>1.10.13"  (or migrate to pydantic 2 with a v2-compatible release)
Defensive patterns

Strategy: validation

Validate before calling

from packaging.version import Version

def version_gt(pkg: str, minimum: str) -> bool:
    return Version(importlib.metadata.version(pkg)) > Version(minimum)

if not version_gt("pydantic", "1.10.13"):
    raise RuntimeError("pydantic too old; upgrade it or use an older integration")

Try / catch

try:
    check_package_version(pkg, gt_version=minimum)
except ValueError as e:
    raise RuntimeError(f"dependency floor violated: {e}") from e

Prevention

When it happens

Trigger: `check_package_version(pkg, gt_version=X)` executes where the installed version is X or older — e.g. an integration that needs `pydantic>=2` (gt `1.x`) or a provider SDK feature introduced after a given release, while the environment still has the old version cached/installed.

Common situations: Long-lived Docker images or_lambda environments with stale dependencies; installing LangChain's latest release into an environment pinned to old dependency majors; partial upgrades where the new integration landed but its dependency did not; system-package managers providing ancient versions.

Related errors


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/1861511d1bda0865. Report an issue: GitHub.