{"record":{"id":"ca3a3ef39fcb9093","repo":"langchain-ai/deepagents","slug":"profile-module-not-found-profiles-path","errorCode":null,"errorMessage":"Profile module not found: {profiles_path}","messagePattern":"Profile module not found: (.+?)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/model_config.py","lineNumber":1411,"sourceCode":"\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}\"\n            raise ImportError(msg)\n\n        file_spec = importlib.util.spec_from_file_location(module_path, profiles_path)\n        if file_spec is None or file_spec.loader is None:\n            msg = f\"Could not create module spec for {profiles_path}\"\n            raise ImportError(msg)\n\n        module = importlib.util.module_from_spec(file_spec)\n        file_spec.loader.exec_module(module)\n        profiles = getattr(module, \"_PROFILES\", {})\n        _provider_profiles_cache[module_path] = profiles\n        return profiles\n\n\ndef _profile_module_from_class_path(class_path: str) -> str | None:\n    \"\"\"Derive the profile module path from a `class_path` config value.\n\n    Args:\n        class_path: Fully-qualified class in `module.path:ClassName` format.","sourceCodeStart":1393,"sourceCodeEnd":1429,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/model_config.py#L1393-L1429","documentation":"_load_provider_profiles computes the on-disk path of the profiles module as <package_dir>/<subpath>/<name>.py and checks that it exists before loading it. If the constructed profiles_path does not exist, it raises ImportError('Profile module not found: {profiles_path}'). This means the root package resolved fine but the expected profiles file inside it is missing.","triggerScenarios":"Calling _discover_available_models() or get_model_profiles() when the configured module_path's non-root segments (e.g. ['data', '_profiles']) do not correspond to an existing .py file inside the resolved package directory.","commonSituations":"Version mismatch: an older/newer provider package layout lacks the internal _profiles.py; a mis-typed module path in configuration; the package was installed as a stripped/minimal build without internal data modules.","solutions":["Reinstall/upgrade the provider package so its bundled `data/_profiles.py` matches what this version of the library expects: `pip install --force-reinstall --upgrade <package>`.","Align library and provider package versions (pin compatible versions) — the internal profiles path changed between releases.","Check the file exists manually at the path printed in the error message; if not, the configured module_path segments are wrong."],"exampleFix":"// before (misconfigured module path)\nmodule_path = \"myprovider.profiles.models\"  # myprovider/profiles/models.py missing\n// after\nmodule_path = \"myprovider.data._profiles\"","handlingStrategy":"try-catch","validationCode":"import importlib.util, pathlib\nspec = importlib.util.find_spec(package_root)\nif spec and spec.origin:\n    p = pathlib.Path(spec.origin).parent.joinpath(*parts[1:-1], parts[-1] + \".py\")\n    if not p.exists():\n        raise SystemExit(f\"Provider package lacks expected profiles file: {p}; upgrade it\")","typeGuard":null,"tryCatchPattern":"try:\n    profiles = get_model_profiles(module_path)\nexcept ImportError:\n    profiles = {}  # provider too old/new for this library version","preventionTips":["Keep the provider package and deepagents-code versions compatible; check changelogs after upgrades.","Use locked installs so internal module layouts stay consistent.","Verify internal module paths after any provider major-version bump."],"tags":["python","import","file-not-found","version-mismatch"],"backgroundTag":"module-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}