langchain-ai/deepagents · error · ExtrasIntrospectionError
Distribution {distribution_name!r} not found; cannot preserv
Error message
Distribution {distribution_name!r} not found; cannot preserve already-installed extras safely What it means
`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.
Source
Thrown at libs/code/deepagents_code/extras_info.py:1257
reliably.
Returns:
Sorted tuple of optional extra statuses. An empty tuple is returned
when the distribution itself is not found.
Raises:
ExtrasIntrospectionError: If `strict` is `True` and metadata
introspection fails.
"""
try:
dist = distribution(distribution_name)
except PackageNotFoundError:
if strict:
msg = (
f"Distribution {distribution_name!r} not found; cannot preserve "
"already-installed extras safely"
)
raise ExtrasIntrospectionError(msg) from None
# Editable installs renamed by the user, dev checkouts without metadata,
# or vendored copies all hit this path. The dependency screen otherwise
# silently renders "none detected" twice; warn so the cause is visible.
logger.warning(
"Distribution %s not found; optional-dependency status will be empty",
distribution_name,
)
return ()
own_name = distribution_name.lower()
installed: dict[str, list[tuple[str, str]]] = {}
missing: dict[str, list[str]] = {}
for raw in dist.requires or []:
try:
req = Requirement(raw)
except InvalidRequirement:
if strict:
msg = (View on GitHub (pinned to a1af029e6e)
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)`
Example fix
// before
status = get_optional_dependency_status("langchain-quickjs", strict=True)
// after
try:
status = get_optional_dependency_status("langchain-quickjs", strict=True)
except ExtrasIntrospectionError:
status = EMPTY_STATUS # or reinstall the distribution Defensive patterns
Strategy: fallback
Validate before calling
from importlib.metadata import distribution
try:
distribution("langchain-quickjs")
except Exception:
# distribution absent; skip strict introspection
pass Type guard
from importlib.metadata import distribution, PackageNotFoundError
def is_installed(name: str) -> bool:
try:
distribution(name); return True
except PackageNotFoundError:
return False Try / catch
try:
status = get_optional_dependency_status(dist, strict=True)
except ExtrasIntrospectionError:
status = {} # degrade to best-effort Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Could not parse optional-dependency metadata; cannot preserv
- Cannot determine location for {package_root}
- uv tool receipt contains invalid extras on the tool requirem
- uv tool receipt contains duplicate canonical extra names
- Extra {extra!r} is a base dependency and cannot be removed.
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/e1f2e9b785e85f4a.
Report an issue: GitHub.