{"record":{"id":"237be328029eb89c","repo":"headroomlabs-ai/headroom","slug":"mem0-package-not-installed-install-with-pip-inst","errorCode":null,"errorMessage":"mem0 package not installed. Install with: pip install 'headroom-ai[memory-stack]'","messagePattern":"mem0 package not installed\\. Install with: pip install 'headroom-ai\\[memory-stack\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"headroom/memory/backends/direct_mem0.py","lineNumber":255,"sourceCode":"                \"embedder\": {\n                    \"provider\": \"openai\",\n                    \"config\": {\"model\": self._config.embedder_model},\n                },\n            }\n\n            if self._config.enable_graph:\n                mem0_config[\"graph_store\"] = {\n                    \"provider\": \"neo4j\",\n                    \"config\": {\n                        \"url\": self._config.neo4j_uri,\n                        \"username\": self._config.neo4j_user,\n                        \"password\": self._config.neo4j_password,\n                    },\n                }\n\n            self._mem0_client = await asyncio.to_thread(Mem0Memory.from_config, mem0_config)\n        except ImportError:\n            raise ImportError(\n                \"mem0 package not installed. Install with: pip install 'headroom-ai[memory-stack]'\"\n            ) from None\n\n        self._initialized = True\n\n    async def ensure_initialized(self) -> None:\n        \"\"\"Public initialization hook for callers that need readiness guarantees.\"\"\"\n        await self._ensure_initialized()\n\n    def _embed(self, text: str) -> list[float]:\n        \"\"\"Generate embedding for text using OpenAI.\"\"\"\n        response = self._openai_client.embeddings.create(\n            input=text,\n            model=self._config.embedder_model,\n        )\n        return list(response.data[0].embedding)\n\n    def _generate_id(self, content: str, user_id: str) -> str:","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/memory/backends/direct_mem0.py#L237-L273","documentation":"Raised by DirectMem0Adapter._ensure_initialized() when the 'mem0' package is missing. After openai and qdrant-client come up, the backend builds a mem0 config and calls Mem0Memory.from_config; an ImportError in that block is re-raised with this message pointing at the headroom-ai[memory-stack] extra, which bundles the whole memory stack.","triggerScenarios":"First memory operation on DirectMem0Adapter when openai and qdrant-client are present but mem0 is not; also reached when 'from mem0 import Memory as Mem0Memory' inside the init block fails (e.g. broken mem0 install raising ImportError internally).","commonSituations":"Hand-picking dependencies instead of using the extra; a corrupted mem0 install whose sub-imports raise ImportError; upgrading headroom without reinstalling extras.","solutions":["pip install 'headroom-ai[memory-stack]'","Verify mem0 imports cleanly: python -c 'from mem0 import Memory' — if this fails with a different ImportError, reinstall mem0 to fix the broken transitive dependency","Use the plain sqlite backend if you do not need mem0 semantics"],"exampleFix":"# before\npip install openai qdrant-client  # mem0 missing\nawait adapter.save('x', user_id='u')  # ImportError: mem0 package not installed\n\n# after\npip install 'headroom-ai[memory-stack]'\nawait adapter.save('x', user_id='u')","handlingStrategy":"validation","validationCode":"import importlib.util\n\nrequired = ['openai', 'qdrant_client', 'mem0', 'neo4j']\nmissing = [m for m in required if importlib.util.find_spec(m) is None]\nif missing:\n    raise SystemExit(f'Missing packages {missing}; run: pip install \"headroom-ai[memory-stack]\"')","typeGuard":null,"tryCatchPattern":"try:\n    await backend.save(content, user_id='u1')\nexcept ImportError as e:\n    logger.error('memory stack incomplete: %s', e)\n    raise","preventionTips":["Prefer the bundled extra over hand-picked packages so mem0, openai, and qdrant-client stay version-aligned","Verify 'from mem0 import Memory' works in the deployment image as a CI step","Initialize the backend explicitly at startup (await backend.ensure_initialized()) to surface errors before requests"],"tags":["python","import","dependency","mem0","memory-stack","memory-backend"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}