{"record":{"id":"661bef5b72112911","repo":"headroomlabs-ai/headroom","slug":"anthropic-package-required-install-with-pip-inst-661bef","errorCode":null,"errorMessage":"anthropic package required. Install with: pip install anthropic","messagePattern":"anthropic package required\\. Install with: pip install anthropic","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"headroom/evals/runners/before_after.py","lineNumber":105,"sourceCode":"        self._proxy_client: Any = None\n        if self.llm_config.headroom_proxy_url:\n            self._proxy_client = self._init_proxy_client()\n\n        # ContentRouter is still used as fallback when no proxy is configured\n        self._router = ContentRouter(config=self.router_config)\n\n        # Lazy-initialized LLM judge for ground-truth evaluation\n        self._judge_fn: Any = None\n\n    def _init_llm_client(self) -> Any:\n        \"\"\"Initialize the appropriate LLM client.\"\"\"\n        if self.llm_config.provider == \"anthropic\":\n            try:\n                import anthropic\n\n                return anthropic.Anthropic()\n            except ImportError as e:\n                raise ImportError(\n                    \"anthropic package required. Install with: pip install anthropic\"\n                ) from e\n        elif self.llm_config.provider == \"openai\":\n            try:\n                import openai\n\n                return openai.OpenAI()\n            except ImportError as e:\n                raise ImportError(\n                    \"openai package required. Install with: pip install openai\"\n                ) from e\n        elif self.llm_config.provider == \"ollama\":\n            try:\n                import ollama\n\n                return ollama.Client()\n            except ImportError as e:\n                raise ImportError(","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/evals/runners/before_after.py#L87-L123","documentation":"Raised by BeforeAfterRunner._init_llm_client when llm_config.provider == 'anthropic' but the anthropic Python package is not importable in the current environment. The eval runner lazily imports the provider SDK only at judge-initialization time, so the failure appears at first ground-truth evaluation, not at runner construction. It is an optional-dependency error with an explicit pip remedy in the message.","triggerScenarios":"Configuring LLMJudgeConfig(provider='anthropic') (or a suite YAML selecting anthropic) and starting a before/after eval run in an environment where 'pip install anthropic' was never executed or the package lives in a different virtualenv than the one running the eval.","commonSituations":"Using the headroom[evals]/eval extra that does not pin every provider SDK; activating the wrong venv/conda env; a Docker image built without provider extras; CI cache serving a stale env.","solutions":["pip install anthropic in the SAME interpreter that runs the eval (python -m pip install anthropic to be sure).","Or install the project's eval extras (e.g. pip install -e '.[evals]') which should pin provider deps.","If you did not intend Anthropic, switch llm_config.provider to a provider whose SDK you have (openai/ollama).","Verify with: python -c \"import anthropic; print(anthropic.__version__)\"."],"exampleFix":"# before\n# LLMJudgeConfig(provider=\"anthropic\") in a bare env -> ImportError at first judge call\n\n# after\n$ python -m pip install anthropic\n# or pin via extras in pyproject: [project.optional-dependencies] evals = [\"anthropic>=0.30\"]","handlingStrategy":"validation","validationCode":"import importlib.util, sys\n\nmissing = [p for p in (\"anthropic\",) if importlib.util.find_spec(p) is None]\nif missing:\n    raise SystemExit(f\"install provider SDKs first: pip install {' '.join(missing)}\")","typeGuard":null,"tryCatchPattern":"try:\n    runner = BeforeAfterRunner(cfg)\n    runner.run()\nexcept ImportError as e:\n    if \"anthropic\" in str(e):\n        sys.exit(\"pip install anthropic (or switch provider) then rerun\")\n    raise","preventionTips":["Install eval extras (pip install -e '.[evals]') in every env that runs suites.","Fail fast at startup: find_spec-check the SDK matching your configured provider.","Pin provider SDK versions in the lockfile so CI never runs half-provisioned."],"tags":["anthropic","import-error","optional-dependency","evals","configuration"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}