{"record":{"id":"91e2e3cd903bc331","repo":"langchain-ai/deepagents","slug":"could-not-import-deep-agents-code-dependencies-or","errorCode":null,"errorMessage":"Could not import Deep Agents Code dependencies or locate dcode on PATH.","messagePattern":"Could not import Deep Agents Code dependencies or locate dcode on PATH\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"critical","filePath":"libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py","lineNumber":101,"sourceCode":"                stderr=subprocess.DEVNULL,\n                check=False,\n                timeout=10,\n            )\n        except (subprocess.TimeoutExpired, OSError):\n            # A hung or non-executable candidate must not abort the search;\n            # skip it and fall through to the next one (or the clear error below).\n            continue\n        if check.returncode == 0:\n            env = os.environ.copy()\n            env[\"DEEPAGENTS_THREAD_INSPECTOR_REEXEC\"] = \"1\"\n            os.execve(  # noqa: S606  # Replaces this process with that interpreter.\n                str(candidate),\n                [str(candidate), str(Path(__file__).resolve()), *sys.argv[1:]],\n                env,\n            )\n\n    msg = \"Could not import Deep Agents Code dependencies or locate dcode on PATH.\"\n    raise SystemExit(msg)\n\n\ndef _default_db_path() -> Path:\n    \"\"\"Return the sessions DB path dcode itself would use.\n\n    Returns:\n        The default sessions database path.\n\n    Raises:\n        SystemExit: If `DEEPAGENTS_HOME` is set to a value dcode rejects, so\n            this script never reads a database dcode never writes.\n    \"\"\"\n    explicit = os.environ.get(\"DEEPAGENTS_SESSIONS_DB\")\n    if explicit:\n        return Path(explicit).expanduser()\n    try:\n        from deepagents_code._paths import get_deepagents_home  # noqa: PLC2701\n    except ImportError:","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L83-L119","documentation":"This is the fallback failure of `_ensure_runtime` in the thread-inspector script: after the script cannot import Deep Agents Code dependencies in the current interpreter AND re-execution attempts against candidates (dcode, deepagents-code, known venv paths) either found nothing on PATH or failed, it exits with this SystemExit message. In short: no usable Python runtime or `dcode` executable with the required dependencies could be found.","triggerScenarios":"Running the script where (1) the current python cannot import deepagents_code, and (2) `shutil.which('dcode')` and `shutil.which('deepagents-code')` both return None (and no venv candidate works), so no re-exec target exists.","commonSituations":"Running the skill on a machine where dcode was never installed; a container/CI image with only the scripts copied but not the package; a PATH that excludes the venv's bin directory (e.g. cron, non-interactive shells).","solutions":["Install deepagents-code so `dcode` is on PATH (verify with `which dcode`), or run the script from within the project environment (`uv run`).","Add the venv bin directory to PATH (e.g. `export PATH=\"$PWD/.venv/bin:$PATH\"`) before invoking the script.","Activate the correct virtualenv first (`source .venv/bin/activate`) so the direct import succeeds without re-exec."],"exampleFix":"// before\n$ /usr/bin/python3 scripts/inspect_sessions.py   # no deps, no dcode on PATH\n// after\n$ source .venv/bin/activate && python scripts/inspect_sessions.py  # or ensure dcode on PATH","handlingStrategy":"fallback","validationCode":"import shutil, importlib.util\nif importlib.util.find_spec('deepagents_code') is None and not (shutil.which('dcode') or shutil.which('deepagents-code')):\n    import sys; sys.exit('Install deepagents-code or add dcode to PATH before running inspect_sessions.py')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure dcode is on PATH in non-interactive contexts (cron/CI) by exporting PATH with the venv bin dir.","Install deepagents-code in the target image before copying skill scripts.","Activate the project venv before invoking the script directly."],"tags":["environment","missing-dependency","path","script"],"backgroundTag":"missing-runtime-dependency","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}