langchain-ai/langchain · error · ValueError
Expected {package} version to be <= {lte_version}. Received
Error message
Expected {package} version to be <= {lte_version}. Received {imported_version}. What it means
Raised by `check_package_version` in `langchain_core.utils.utils` for the inclusive upper bound: the installed `package` version is strictly greater than `lte_version`. This is the same ceiling guard as the `<` variant, but the boundary version itself is allowed (e.g. `lte_version="1.2.3"` accepts 1.2.3, rejects 1.2.4+). It fails at import/first use of the guarded integration.
Source
Thrown at libs/core/langchain_core/utils/utils.py:178
gte_version: The version must be greater than or equal to this.
Raises:
ValueError: If the package version does not meet the requirements.
"""
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:View on GitHub (pinned to e32fa9a52e)
Solutions
- Pin the dependency at or below the boundary from the message (`pip install "pkg<=X"`), or better, exact-pin to the lockfile version.
- Upgrade the LangChain integration package to a release compatible with the newer dependency.
- In monorepos, run `uv sync` against the committed lockfile instead of resolving fresh.
Example fix
# before # ValueError: Expected openai version to be <= 1.40.0. Received 1.55.1. # after (terminal) # pip install "openai<=1.40.0" # or: pip install -U langchain-openai (integration supporting newer openai)
Defensive patterns
Strategy: validation
Validate before calling
from packaging.version import Version
def version_lte(pkg: str, ceiling: str) -> bool:
return Version(importlib.metadata.version(pkg)) <= Version(ceiling)
if not version_lte("openai", "1.40.0"):
raise RuntimeError("openai too new for this integration; pin or upgrade integration") Try / catch
try:
check_package_version(pkg, lte_version=ceiling)
except ValueError as e:
raise RuntimeError(f"dependency ceiling violated: {e}") from e Prevention
- Commit and install lockfiles so transitive upgrades cannot pass validated ceilings.
- Upgrade integration and dependency together in one PR.
- Assert dependency versions during application startup.
When it happens
Trigger: `check_package_version(pkg, lte_version=X)` runs with an installed version above X — typically after upgrading the dependency (e.g. `openai` SDK or `pydantic`) past the last version the installed LangChain integration was validated against.
Common situations: Fresh environments installing newest dependency versions alongside older pinned LangChain releases; Dependabot-style automated upgrades; local development on the dependency's new major while the integration expects the previous one.
Related errors
- Expected {package} version to be < {lt_version}. Received {i
- Expected {package} version to be > {gt_version}. Received {i
- Expected {package} version to be >= {gte_version}. Received
- Could not import {module_name} python package. Please instal
- Tracing using LangChainTracerV1 is no longer supported. Plea
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/4428c9f6dd6e15ff.
Report an issue: GitHub.