chroma-core/chroma · error · ValueError

The cohere python package is not installed. Please install i

Error message

The cohere python package is not installed. Please install it with `pip install cohere`

What it means

Chroma keeps provider SDKs optional; CohereEmbeddingFunction imports cohere lazily in __init__ and raises this ValueError when the import fails. Nothing about your Chroma usage or credentials is wrong - the constructor simply cannot build cohere.Client without the package.

Source

Thrown at chromadb/utils/embedding_functions/cohere_embedding_function.py:29

import numpy as np
from chromadb.utils.embedding_functions.schemas import validate_config_schema
import base64
import io
import importlib
import warnings


class CohereEmbeddingFunction(EmbeddingFunction[Embeddable]):
    def __init__(
        self,
        api_key: Optional[str] = None,
        model_name: str = "large",
        api_key_env_var: str = "CHROMA_COHERE_API_KEY",
    ):
        try:
            import cohere
        except ImportError:
            raise ValueError(
                "The cohere python package is not installed. Please install it with `pip install cohere`"
            )

        try:
            self._PILImage = importlib.import_module("PIL.Image")
        except ImportError:
            raise ValueError(
                "The PIL python package is not installed. Please install it with `pip install pillow`"
            )

        if api_key is not None:
            warnings.warn(
                "Direct api_key configuration will not be persisted. "
                "Please use environment variables via api_key_env_var for persistent storage.",
                DeprecationWarning,
            )
        if os.getenv("COHERE_API_KEY") is not None:
            self.api_key_env_var = "COHERE_API_KEY"

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. pip install cohere in the environment that runs Chroma, then retry construction.
  2. Pin cohere in requirements.txt/pyproject.toml so installs stay reproducible.
  3. Verify with python -c 'import cohere' from the same interpreter you run Chroma with.

Example fix

# before
from chromadb.utils.embedding_functions import CohereEmbeddingFunction
ef = CohereEmbeddingFunction()  # ValueError: cohere not installed

# after
# pip install cohere
from chromadb.utils.embedding_functions import CohereEmbeddingFunction
ef = CohereEmbeddingFunction(model_name='embed-english-v3.0')
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec('cohere') is None:
    raise SystemExit('pip install cohere before using CohereEmbeddingFunction')

Try / catch

try:
    from chromadb.utils.embedding_functions import CohereEmbeddingFunction
    ef = CohereEmbeddingFunction()
except ValueError as e:
    if 'cohere' in str(e):
        raise SystemExit(f'Dependency missing: {e}') from e
    raise

Prevention

When it happens

Trigger: CohereEmbeddingFunction(model_name=...) constructed in an interpreter where the cohere distribution is missing - fresh venv, pruned container image, stale lockfile.

Common situations: A teammate adds the Cohere embedding function without updating requirements; CI cache built before cohere was needed; different venv between IDE and runtime.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/791d1d156c1a0539. Report an issue: GitHub.