langchain-ai/deepagents · error · ImportError
Profile module not found: {profiles_path}
Error message
Profile module not found: {profiles_path} What it means
_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.
Source
Thrown at libs/code/deepagents_code/model_config.py:1411
# Determine the package directory from the spec.
if spec.origin:
package_dir = Path(spec.origin).parent
elif spec.submodule_search_locations:
package_dir = Path(next(iter(spec.submodule_search_locations)))
else:
msg = f"Cannot determine location for {package_root}"
raise ImportError(msg)
# Build the path to the target file (e.g., data/_profiles.py).
relative_parts = parts[1:] # ["data", "_profiles"]
profiles_path = package_dir.joinpath(
*relative_parts[:-1], f"{relative_parts[-1]}.py"
)
if not profiles_path.exists():
msg = f"Profile module not found: {profiles_path}"
raise ImportError(msg)
file_spec = importlib.util.spec_from_file_location(module_path, profiles_path)
if file_spec is None or file_spec.loader is None:
msg = f"Could not create module spec for {profiles_path}"
raise ImportError(msg)
module = importlib.util.module_from_spec(file_spec)
file_spec.loader.exec_module(module)
profiles = getattr(module, "_PROFILES", {})
_provider_profiles_cache[module_path] = profiles
return profiles
def _profile_module_from_class_path(class_path: str) -> str | None:
"""Derive the profile module path from a `class_path` config value.
Args:
class_path: Fully-qualified class in `module.path:ClassName` format.View on GitHub (pinned to a1af029e6e)
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.
Example fix
// before (misconfigured module path) module_path = "myprovider.profiles.models" # myprovider/profiles/models.py missing // after module_path = "myprovider.data._profiles"
Defensive patterns
Strategy: try-catch
Validate before calling
import importlib.util, pathlib
spec = importlib.util.find_spec(package_root)
if spec and spec.origin:
p = pathlib.Path(spec.origin).parent.joinpath(*parts[1:-1], parts[-1] + ".py")
if not p.exists():
raise SystemExit(f"Provider package lacks expected profiles file: {p}; upgrade it") Try / catch
try:
profiles = get_model_profiles(module_path)
except ImportError:
profiles = {} # provider too old/new for this library version Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not import module '{module_path}' for provider '{provi
- Could not import extension {source.path}
- Missing dependencies for '{provider}' sandbox. {install_hint
- Class '{class_name}' not found in module '{module_path}'
- Package {package_root} is not installed
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/ca3a3ef39fcb9093.
Report an issue: GitHub.