{"record":{"id":"8914b0e671051ff3","repo":"langchain-ai/deepagents","slug":"package-package-root-is-not-installed","errorCode":null,"errorMessage":"Package {package_root} is not installed","messagePattern":"Package (.+?) is not installed","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/model_config.py","lineNumber":1392,"sourceCode":"        The `_PROFILES` dictionary from the module, or an empty dict if\n            the module has no such attribute.\n\n    Raises:\n        ImportError: If the package is not installed or the profile module\n            cannot be found on disk.\n    \"\"\"\n    with _provider_profiles_lock:\n        cached = _provider_profiles_cache.get(module_path)\n        if cached is not None:  # `is not None` so empty profile dicts are cached\n            return cached\n\n        parts = module_path.split(\".\")\n        package_root = parts[0]\n\n        spec = importlib.util.find_spec(package_root)\n        if spec is None:\n            msg = f\"Package {package_root} is not installed\"\n            raise ImportError(msg)\n\n        # Determine the package directory from the spec.\n        if spec.origin:\n            package_dir = Path(spec.origin).parent\n        elif spec.submodule_search_locations:\n            package_dir = Path(next(iter(spec.submodule_search_locations)))\n        else:\n            msg = f\"Cannot determine location for {package_root}\"\n            raise ImportError(msg)\n\n        # Build the path to the target file (e.g., data/_profiles.py).\n        relative_parts = parts[1:]  # [\"data\", \"_profiles\"]\n        profiles_path = package_dir.joinpath(\n            *relative_parts[:-1], f\"{relative_parts[-1]}.py\"\n        )\n\n        if not profiles_path.exists():\n            msg = f\"Profile module not found: {profiles_path}\"","sourceCodeStart":1374,"sourceCodeEnd":1410,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/model_config.py#L1374-L1410","documentation":"_load_provider_profiles resolves a dotted module path (e.g. `provider.data._profiles`) by first locating the top-level package with importlib.util.find_spec. If the root package cannot be found on sys.path, it raises ImportError('Package {package_root} is not installed'). The library throws this because provider profiles are loaded lazily from optional provider packages, so a missing dependency is reported as an explicit, actionable ImportError rather than a silent empty profile set.","triggerScenarios":"Calling _discover_available_models() or get_model_profiles() when the top-level package name in the configured module_path is not importable — i.e. find_spec(parts[0]) returns None because the provider package is not installed in the active environment.","commonSituations":"The provider extra is not installed (e.g. missing `pip install deepagents-code[anthropic]`); the app runs in a venv/poetry/uv environment different from the one where providers were installed; a typo'd or renamed package name in configuration; the package was uninstalled or upgraded with a new import name.","solutions":["Install the missing provider package into the active interpreter: `pip install <package_root>` or the matching extras, e.g. `uv pip install deepagents-code[<provider>]`.","Verify you are in the intended environment: `which python` / `python -c \"import <package_root>\"`.","Check the module_path configured for the provider for typos; the first dotted segment must be the real installed distribution's import name."],"exampleFix":"// before (module path points at uninstalled package)\nmodule_path = \"anthropic_provider.data._profiles\"  # ImportError\n// after (install the package first)\n# pip install anthropic-provider\nmodule_path = \"anthropic_provider.data._profiles\"","handlingStrategy":"fallback","validationCode":"import importlib.util\nif importlib.util.find_spec(package_root) is None:\n    raise SystemExit(f\"Install missing provider package: {package_root}\")","typeGuard":null,"tryCatchPattern":"try:\n    profiles = get_model_profiles(module_path)\nexcept ImportError:\n    profiles = {}  # fall back to default profiles and warn the user","preventionTips":["Install provider extras explicitly (pip install deepagents-code[<provider>]) in every environment.","Pin and lock dependencies so dev/CI/prod environments match.","Run a startup smoke test that imports each configured provider package."],"tags":["python","import","dependency-missing","config"],"backgroundTag":"module-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}