{"record":{"id":"d8fdee7072582b79","repo":"microsoft/semantic-kernel","slug":"could-not-import-chromadb-python-package-please-i","errorCode":null,"errorMessage":"Could not import chromadb python package. Please install it with `pip install chromadb`.","messagePattern":"Could not import chromadb python package\\. Please install it with `pip install chromadb`\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/chroma/chroma_memory_store.py","lineNumber":78,"sourceCode":"\n        Example:\n            # Create a ChromaMemoryStore with a local specified directory for data persistence\n            chroma_local_data_store = ChromaMemoryStore(persist_directory='/path/to/persist/directory')\n            # Create a ChromaMemoryStore with a custom Settings instance\n            chroma_remote_data_store = ChromaMemoryStore(\n                client_settings=Settings(\n                    chroma_api_impl=\"rest\",\n                    chroma_server_host=\"xxx.xxx.xxx.xxx\",\n                    chroma_server_http_port=\"8000\"\n                )\n            )\n        \"\"\"\n        try:\n            import chromadb\n            import chromadb.config\n\n        except ImportError as exc:\n            raise ServiceInitializationError(\n                \"Could not import chromadb python package. Please install it with `pip install chromadb`.\"\n            ) from exc\n\n        if client_settings:\n            self._client_settings = client_settings\n        else:\n            self._client_settings = chromadb.config.Settings()\n            if persist_directory is not None:\n                self._client_settings = chromadb.config.Settings(\n                    is_persistent=True, persist_directory=persist_directory\n                )\n        self._client = chromadb.Client(self._client_settings)\n        self._persist_directory = persist_directory\n        self._default_query_includes = [\"embeddings\", \"metadatas\", \"documents\"]\n\n    async def create_collection(self, collection_name: str) -> None:\n        \"\"\"Creates a new collection in Chroma if it does not exist.\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/chroma/chroma_memory_store.py#L60-L96","documentation":"Raised as a ServiceInitializationError when ChromaMemoryStore.__init__ cannot import the chromadb package. The store lazily imports chromadb inside a try/except; any ImportError (package not installed, broken install, or incompatible version) is wrapped into this error with an install hint.","triggerScenarios":"Instantiating ChromaMemoryStore() in an environment where chromadb is not installed. Also triggered if chromadb is installed but a transitive dependency (e.g. onnxruntime, pulsar-client, duckdb) is missing or the Python version is incompatible, causing the import line itself to raise ImportError.","commonSituations":"Installing semantic-kernel without the chroma extra (pip install semantic-kernel vs pip install semantic-kernel[chroma]). Using a slim Docker image that omits chromadb. A corrupted venv or a pip install that failed partway. Python version mismatch with chromadb's requirements.","solutions":["Install chromadb: pip install chromadb (or pip install semantic-kernel[chroma] to get the pinned extra).","Verify the import works in isolation: python -c 'import chromadb; print(chromadb.__version__)'.","If the import still fails after install, recreate the virtualenv to clear partial installs.","Pin a compatible chromadb version known to work with your Python interpreter."],"exampleFix":"// before (no chromadb installed)\nstore = ChromaMemoryStore()  # ServiceInitializationError\n// after\n# pip install chromadb\nstore = ChromaMemoryStore(persist_directory='./chroma_data')","handlingStrategy":"validation","validationCode":"def chromadb_available() -> bool:\n    try:\n        import chromadb  # noqa: F401\n        import chromadb.config  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif not chromadb_available():\n    raise SystemExit('Install chromadb: pip install chromadb')","typeGuard":"def chromadb_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec('chromadb') is not None","tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\n\ntry:\n    store = ChromaMemoryStore()\nexcept ServiceInitializationError as e:\n    if 'chromadb' in str(e):\n        logging.error('chromadb not installed: %s', e)\n    raise","preventionTips":["Install via pip install semantic-kernel[chroma] to get the pinned extra.","Pin a chromadb version compatible with your Python interpreter.","Verify the import in CI before running integration tests.","Use a complete Docker image rather than a slim base that omits chromadb."],"tags":["chroma","dependency","import","initialization","python"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}