{"record":{"id":"d54cd99caab82715","repo":"mem0ai/mem0","slug":"the-chromadb-library-is-required-please-install","errorCode":null,"errorMessage":"The 'chromadb' library is required. Please install it using 'pip install chromadb'.","messagePattern":"The 'chromadb' library is required\\. Please install it using 'pip install chromadb'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"mem0/configs/vector_stores/chroma.py","lineNumber":10,"sourceCode":"from typing import Any, ClassVar, Dict, Optional\n\nfrom pydantic import BaseModel, ConfigDict, Field, model_validator\n\n\nclass ChromaDbConfig(BaseModel):\n    try:\n        from chromadb.api.client import Client\n    except ImportError:\n        raise ImportError(\"The 'chromadb' library is required. Please install it using 'pip install chromadb'.\")\n    Client: ClassVar[type] = Client\n\n    collection_name: str = Field(\"mem0\", description=\"Default name for the collection/database\")\n    client: Optional[Client] = Field(None, description=\"Existing ChromaDB client instance\")\n    path: Optional[str] = Field(None, description=\"Path to the database directory\")\n    host: Optional[str] = Field(None, description=\"Database connection remote host\")\n    port: Optional[int] = Field(None, description=\"Database connection remote port\")\n    # ChromaDB Cloud configuration\n    api_key: Optional[str] = Field(None, description=\"ChromaDB Cloud API key\")\n    tenant: Optional[str] = Field(None, description=\"ChromaDB Cloud tenant ID\")\n\n    @model_validator(mode=\"before\")\n    def check_connection_config(cls, values):\n        host, port, path = values.get(\"host\"), values.get(\"port\"), values.get(\"path\")\n        api_key, tenant = values.get(\"api_key\"), values.get(\"tenant\")\n        \n        # Check if cloud configuration is provided\n        cloud_config = bool(api_key and tenant)","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/chroma.py#L1-L28","documentation":"ImportError raised at class-definition time in ChromaDbConfig: the module body tries 'from chromadb.api.client import Client' and if chromadb is not installed the config class itself fails to import. This is a hard dependency gate, not a runtime validation — you cannot even construct the config without the package.","triggerScenarios":"Using the chroma vector store (Memory with vector_store.provider='chroma') in an environment where the chromadb package is missing, or installed in a different interpreter/venv than the one running mem0. Because it executes at import of mem0.configs.vector_stores.chroma, the failure can surface when mem0 lazily loads the vector store module.","commonSituations":"Installing mem0ai without vector-store extras and then selecting chroma; deploying to a slim Docker image that pruned 'unused' deps; a broken chromadb install (partial wheel) that makes the submodule import fail; multiple virtualenvs where the app runs in the one without chromadb.","solutions":["Install chromadb into the same environment running mem0: pip install chromadb","If using extras, install mem0ai with the appropriate vector-store extra for chroma","Verify with 'python -c \"import chromadb\"' in the exact interpreter/venv the app uses","If the import fails despite installation, reinstall chromadb to repair a partial/corrupted install"],"exampleFix":"# before\npip install mem0ai\n# then Memory.from_config({\"vector_store\": {\"provider\": \"chroma\", ...}}) -> ImportError\n\n# after\npip install mem0ai chromadb","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec(\"chromadb\") is None:\n    raise RuntimeError(\"chromadb is required for the chroma vector store: pip install chromadb\")","typeGuard":null,"tryCatchPattern":"try:\n    from mem0.configs.vector_stores.chroma import ChromaDbConfig\nexcept ImportError as e:\n    if \"chromadb\" in str(e):\n        # install chromadb or fall back to another vector store provider\n        ...","preventionTips":["Declare chromadb in the same requirements/env spec as mem0 when using the chroma provider","Add a dependency preflight (find_spec) before selecting the provider at runtime","Verify installs in the exact interpreter the app runs under"],"tags":["import-error","dependency","vector-store","chroma","packaging"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}