microsoft/semantic-kernel · error · ServiceInitializationError
Could not import chromadb python package. Please install it
Error message
Could not import chromadb python package. Please install it with `pip install chromadb`.
What it means
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.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/chroma/chroma_memory_store.py:78
Example:
# Create a ChromaMemoryStore with a local specified directory for data persistence
chroma_local_data_store = ChromaMemoryStore(persist_directory='/path/to/persist/directory')
# Create a ChromaMemoryStore with a custom Settings instance
chroma_remote_data_store = ChromaMemoryStore(
client_settings=Settings(
chroma_api_impl="rest",
chroma_server_host="xxx.xxx.xxx.xxx",
chroma_server_http_port="8000"
)
)
"""
try:
import chromadb
import chromadb.config
except ImportError as exc:
raise ServiceInitializationError(
"Could not import chromadb python package. Please install it with `pip install chromadb`."
) from exc
if client_settings:
self._client_settings = client_settings
else:
self._client_settings = chromadb.config.Settings()
if persist_directory is not None:
self._client_settings = chromadb.config.Settings(
is_persistent=True, persist_directory=persist_directory
)
self._client = chromadb.Client(self._client_settings)
self._persist_directory = persist_directory
self._default_query_includes = ["embeddings", "metadatas", "documents"]
async def create_collection(self, collection_name: str) -> None:
"""Creates a new collection in Chroma if it does not exist.
View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before (no chromadb installed) store = ChromaMemoryStore() # ServiceInitializationError // after # pip install chromadb store = ChromaMemoryStore(persist_directory='./chroma_data')
Defensive patterns
Strategy: validation
Validate before calling
def chromadb_available() -> bool:
try:
import chromadb # noqa: F401
import chromadb.config # noqa: F401
return True
except ImportError:
return False
if not chromadb_available():
raise SystemExit('Install chromadb: pip install chromadb') Type guard
def chromadb_available() -> bool:
import importlib.util
return importlib.util.find_spec('chromadb') is not None Try / catch
from semantic_kernel.exceptions import ServiceInitializationError
try:
store = ChromaMemoryStore()
except ServiceInitializationError as e:
if 'chromadb' in str(e):
logging.error('chromadb not installed: %s', e)
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- onnxruntime-genai is not installed.
- The OpenAI text model ID is required.
- The OpenAI embedding model ID is required.
- The OpenAI text to audio model ID is required.
- The OpenAI text to image model ID is required.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/d8fdee7072582b79.
Report an issue: GitHub.