{"record":{"id":"60873479920df72f","repo":"headroomlabs-ai/headroom","slug":"httpx-is-required-for-ollamaembedder-install-it-w","errorCode":null,"errorMessage":"httpx is required for OllamaEmbedder. Install it with: pip install httpx","messagePattern":"httpx is required for OllamaEmbedder\\. Install it with: pip install httpx","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"headroom/memory/adapters/embedders.py","lineNumber":869,"sourceCode":"        Raises:\n            ImportError: If httpx library is not installed.\n        \"\"\"\n        self._check_dependencies()\n\n        self._model_name = model_name or self.DEFAULT_MODEL\n        self._base_url = (base_url or self.DEFAULT_BASE_URL).rstrip(\"/\")\n        self._max_retries = max_retries if max_retries is not None else self.MAX_RETRIES\n        self._explicit_dimension = dimension\n        self._detected_dimension: int | None = None\n        self._client: Any = None  # httpx.AsyncClient when initialized\n        self._lock = asyncio.Lock()\n\n    def _check_dependencies(self) -> None:\n        \"\"\"Check that required dependencies are installed.\"\"\"\n        try:\n            import httpx  # noqa: F401\n        except ImportError as e:\n            raise ImportError(\n                \"httpx is required for OllamaEmbedder. Install it with: pip install httpx\"\n            ) from e\n\n    async def _get_client(self) -> Any:\n        \"\"\"Get or create the httpx async client.\"\"\"\n        if self._client is None:\n            import httpx\n\n            self._client = httpx.AsyncClient(\n                base_url=self._base_url,\n                timeout=self.REQUEST_TIMEOUT,\n            )\n        return self._client\n\n    async def _embed_single_with_retry(self, text: str) -> np.ndarray:\n        \"\"\"Call Ollama API with retry logic for a single text.\n\n        Args:","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/memory/adapters/embedders.py#L851-L887","documentation":"OllamaEmbedder._check_dependencies probes for the httpx package during __init__ and raises this ImportError (chaining the original) when missing. httpx is the HTTP client used for the async /api/embed calls against a local Ollama server; it is an optional dependency from headroom's perspective, so environments without it fail here at construction time, not mid-request.","triggerScenarios":"Constructing OllamaEmbedder() (e.g. via the memory factory or config selecting the ollama embedder) in an environment where httpx isn't installed — slim containers, minimal CI, or a fresh venv without extras.","commonSituations":"Docker images built for the OpenAI path that later switch embedder config to ollama; dependency resolver uninstalling httpx; python 3.13 pre-release wheels missing for httpx deps (h11/httpcore); venv mismatch (httpx installed globally).","solutions":["pip install httpx in the active interpreter.","Install headroom with the embeddings/local extras so httpx is pulled in by default.","Verify interpreter alignment: python -m pip install httpx using the same python that runs your app.","If httpx cannot be installed, use LocalEmbedder (sentence-transformers) instead."],"exampleFix":"# before\nemb = OllamaEmbedder()  # ImportError: httpx is required\n\n# after (shell)\npip install httpx\nemb = OllamaEmbedder()","handlingStrategy":"validation","validationCode":"def ollama_deps_available() -> bool:\n    try:\n        import httpx  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif not ollama_deps_available():\n    raise SystemExit(\"pip install httpx before using OllamaEmbedder\")","typeGuard":null,"tryCatchPattern":"try:\n    emb = OllamaEmbedder()\nexcept ImportError as e:\n    if \"httpx\" in str(e):\n        raise SystemExit(\"pip install httpx to use OllamaEmbedder\") from e\n    raise","preventionTips":["Include httpx in your dependency set whenever the ollama embedder is configured.","Run a dependency preflight at app startup covering all configured embedders.","Use python -m pip to guarantee installs land in the running interpreter."],"tags":["dependencies","import","ollama","embeddings","memory"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}