{"record":{"id":"b81c0e5f0407b176","repo":"langchain-ai/langchain","slug":"expected-package-version-to-be-gte-version","errorCode":null,"errorMessage":"Expected {package} version to be >= {gte_version}. Received {imported_version}.","messagePattern":"Expected (.+?) version to be >= (.+?)\\. Received (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/utils/utils.py","lineNumber":190,"sourceCode":"        raise ValueError(msg)\n    if lte_version is not None and imported_version > parse(lte_version):\n        msg = (\n            f\"Expected {package} version to be <= {lte_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)\n    if gt_version is not None and imported_version <= parse(gt_version):\n        msg = (\n            f\"Expected {package} version to be > {gt_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)\n    if gte_version is not None and imported_version < parse(gte_version):\n        msg = (\n            f\"Expected {package} version to be >= {gte_version}. Received \"\n            f\"{imported_version}.\"\n        )\n        raise ValueError(msg)\n\n\ndef get_pydantic_field_names(pydantic_cls: Any) -> set[str]:\n    \"\"\"Get field names, including aliases, for a pydantic class.\n\n    Args:\n        pydantic_cls: Pydantic class.\n\n    Returns:\n        Field names.\n    \"\"\"\n    all_required_field_names = set()\n    if is_pydantic_v1_subclass(pydantic_cls):\n        for field in pydantic_cls.__fields__.values():\n            all_required_field_names.add(field.name)\n            if field.has_alias:\n                all_required_field_names.add(field.alias)\n    else:  # Assuming pydantic 2 for now","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/utils/utils.py#L172-L208","documentation":"Raised by the version-check utility in `langchain_core.utils.utils` when an installed optional package's version is older than the minimum version (`gte_version`) that a LangChain integration requires. The check parses the imported package's `__version__` and compares it against the declared floor, raising `ValueError` when the installed release predates it. This exists to fail fast with a clear message instead of hitting obscure `AttributeError`/`ImportError` crashes from older APIs.","triggerScenarios":"Importing or instantiating an integration whose module-level code calls the version guard (e.g. `langchain_openai` requiring `openai >= X`) while the installed dependency is older than `gte_version`. Also triggered by explicitly calling the check helper with a `gte_version` argument against an outdated environment.","commonSituations":"Pinned or frozen `requirements.txt`/`uv.lock` with stale optional dependencies after upgrading `langchain-core` or a partner package; CI images built from old base layers; mixing system-installed and venv-installed packages so an old version shadows the new one.","solutions":["Upgrade the offending package to at least the version named in the message, e.g. `uv pip install -U openai` (or whatever `{package}` is).","If using a lockfile, refresh it: run `uv sync --all-groups` / `uv lock --upgrade-package <package>` from the package directory.","Check for duplicate installations (`uv pip list | grep <package>` or `pip show <package>`) and remove the stale copy that shadows the upgraded one.","If you cannot upgrade, pin the LangChain integration to an older release whose minimum version requirement you already satisfy."],"exampleFix":"# before\nuv pip install \"openai==0.27.0\"\nfrom langchain_openai import ChatOpenAI  # ValueError: Expected openai version to be >= 1.x\n\n# after\nuv pip install -U openai\nfrom langchain_openai import ChatOpenAI  # ok","handlingStrategy":"validation","validationCode":"from importlib.metadata import version, PackageNotFoundError\nfrom packaging.version import parse\n\nMIN_VERSIONS = {\"openai\": \"1.60.0\"}  # floors required by your integrations\n\nfor pkg, floor in MIN_VERSIONS.items():\n    try:\n        installed = parse(version(pkg))\n    except PackageNotFoundError:\n        raise SystemExit(f\"{pkg} is not installed\")\n    if installed < parse(floor):\n        raise SystemExit(f\"Upgrade {pkg}: have {installed}, need >= {floor}\")","typeGuard":null,"tryCatchPattern":"try:\n    from langchain_openai import ChatOpenAI\nexcept ValueError as e:  # version guard raised at import time\n    raise SystemExit(f\"Dependency version problem: {e}. Run `uv sync --all-groups`.\") from e","preventionTips":["Keep one lockfile per package (`uv.lock`) and install only through `uv sync`, never ad-hoc pip installs.","Run `uv lock --upgrade` in a scheduled CI job so dependency floors surface as PR failures, not runtime errors.","Print dependency versions at startup during debugging to catch shadowed/stale installs."],"tags":["versioning","dependencies","environment"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}