{"record":{"id":"e1f2e9b785e85f4a","repo":"langchain-ai/deepagents","slug":"distribution-distribution-name-r-not-found-cann","errorCode":null,"errorMessage":"Distribution {distribution_name!r} not found; cannot preserve already-installed extras safely","messagePattern":"Distribution (.+?) not found; cannot preserve already-installed extras safely","errorType":"exception","errorClass":"ExtrasIntrospectionError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/extras_info.py","lineNumber":1257,"sourceCode":"            reliably.\n\n    Returns:\n        Sorted tuple of optional extra statuses. An empty tuple is returned\n            when the distribution itself is not found.\n\n    Raises:\n        ExtrasIntrospectionError: If `strict` is `True` and metadata\n            introspection fails.\n    \"\"\"\n    try:\n        dist = distribution(distribution_name)\n    except PackageNotFoundError:\n        if strict:\n            msg = (\n                f\"Distribution {distribution_name!r} not found; cannot preserve \"\n                \"already-installed extras safely\"\n            )\n            raise ExtrasIntrospectionError(msg) from None\n        # Editable installs renamed by the user, dev checkouts without metadata,\n        # or vendored copies all hit this path. The dependency screen otherwise\n        # silently renders \"none detected\" twice; warn so the cause is visible.\n        logger.warning(\n            \"Distribution %s not found; optional-dependency status will be empty\",\n            distribution_name,\n        )\n        return ()\n\n    own_name = distribution_name.lower()\n    installed: dict[str, list[tuple[str, str]]] = {}\n    missing: dict[str, list[str]] = {}\n    for raw in dist.requires or []:\n        try:\n            req = Requirement(raw)\n        except InvalidRequirement:\n            if strict:\n                msg = (","sourceCodeStart":1239,"sourceCodeEnd":1275,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/extras_info.py#L1239-L1275","documentation":"`get_optional_dependency_status` looks up the installed distribution's metadata (to parse its `Requires-Dist` extras markers). If the named distribution is not installed and `strict=True`, it raises `ExtrasIntrospectionError` because it cannot safely preserve already-installed extras without the metadata. With `strict=False` it only logs a warning and returns empty status.","triggerScenarios":"Calling `get_optional_dependency_status(..., strict=True)` for a distribution name that `importlib.metadata` cannot find — the package isn't installed, was renamed, or is an editable/dev checkout without dist-info metadata.","commonSituations":"User renamed an editable install directory; running from a vendored copy without packaging metadata; checking an extra of a package that was pip-uninstalled while dcode still references it; wrong distribution name passed (e.g. `dcode` vs actual dist name).","solutions":["Install the missing distribution (e.g. `pip install langchain-quickjs` or `pip install -e .[extra]`)","Pass `strict=False` if a missing distribution is acceptable and you only need best-effort status","Verify the distribution name matches the installed metadata (`pip show <name>` / `importlib.metadata.distribution(name)`"],"exampleFix":"// before\nstatus = get_optional_dependency_status(\"langchain-quickjs\", strict=True)\n\n// after\ntry:\n    status = get_optional_dependency_status(\"langchain-quickjs\", strict=True)\nexcept ExtrasIntrospectionError:\n    status = EMPTY_STATUS  # or reinstall the distribution","handlingStrategy":"fallback","validationCode":"from importlib.metadata import distribution\ntry:\n    distribution(\"langchain-quickjs\")\nexcept Exception:\n    # distribution absent; skip strict introspection\n    pass","typeGuard":"from importlib.metadata import distribution, PackageNotFoundError\ndef is_installed(name: str) -> bool:\n    try:\n        distribution(name); return True\n    except PackageNotFoundError:\n        return False","tryCatchPattern":"try:\n    status = get_optional_dependency_status(dist, strict=True)\nexcept ExtrasIntrospectionError:\n    status = {}  # degrade to best-effort","preventionTips":["Check `importlib.metadata.distribution(name)` before strict introspection","Prefer strict=False when a missing dist is tolerable","Verify editable installs keep their dist-info metadata intact"],"tags":["packaging","metadata","extras"],"backgroundTag":"distribution-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}