chroma-core/chroma · error · ValueError

The ollama python package is not installed. Please install i

Error message

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

What it means

OllamaEmbeddingFunction.__init__ does `from ollama import Client` inside a try/except ImportError and converts a missing package into a ValueError with install instructions. The import is deferred to construction so that importing chromadb itself never requires ollama; only users who actually instantiate this EF need the dependency. The default target is a local Ollama server at http://localhost:11434 with model chroma/all-minilm-l6-v2-f32.

Source

Thrown at chromadb/utils/embedding_functions/ollama_embedding_function.py:34

    def __init__(
        self,
        url: str = "http://localhost:11434",
        model_name: str = DEFAULT_MODEL_NAME,
        timeout: int = 60,
    ) -> None:
        """
        Initialize the Ollama Embedding Function.

        Args:
            url (str): The Base URL of the Ollama Server (default: "http://localhost:11434").
            model_name (str): The name of the model to use for text embeddings.
                Defaults to "chroma/all-minilm-l6-v2-f32", for available models see https://ollama.com/library.
            timeout (int): The timeout for the API call in seconds. Defaults to 60.
        """
        try:
            from ollama import Client
        except ImportError:
            raise ValueError(
                "The ollama python package is not installed. Please install it with `pip install ollama`"
            )

        self.url = url
        self.model_name = model_name
        self.timeout = timeout

        # Adding this for backwards compatibility with the old version of the EF
        self._base_url = url
        if self._base_url.endswith("/api/embeddings"):
            parsed_url = urlparse(url)
            self._base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"

        self._client = Client(host=self._base_url, timeout=timeout)

    def __call__(self, input: Documents) -> Embeddings:
        """
        Get the embeddings for a list of texts.

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. pip install ollama into the same interpreter/venv that runs Chroma (verify with `python -m pip show ollama`)
  2. Add ollama to requirements.txt/pyproject next to chromadb for reproducible environments
  3. If you intentionally run without Ollama, pick a different EF (e.g. DefaultEmbeddingFunction) instead of this one

Example fix

// before
fn = OllamaEmbeddingFunction(url="http://localhost:11434", model_name="nomic-embed-text")  # ValueError: package not installed

// after (shell)
pip install ollama
// then
fn = OllamaEmbeddingFunction(url="http://localhost:11434", model_name="nomic-embed-text")
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec("ollama") is None:
    raise SystemExit("ollama package missing: pip install ollama")
fn = OllamaEmbeddingFunction(url="http://localhost:11434", model_name="nomic-embed-text")

Try / catch

try:
    fn = OllamaEmbeddingFunction(url=..., model_name=...)
except ValueError as e:
    if "not installed" in str(e):
        raise SystemExit("Run: pip install ollama") from e
    raise

Prevention

When it happens

Trigger: Constructing OllamaEmbeddingFunction(url=..., model_name=...) in an environment where `pip install ollama` was never run; a venv mismatch where ollama was installed into a different interpreter than the one running Chroma; a fresh clone/CI image that only installs chromadb.

Common situations: Local-dev-vs-CI dependency drift (ollama installed on the laptop, not in the Docker image); mixing system Python and a project venv; upgrading Chroma in an environment whose requirements.txt pins only chromadb.

Related errors


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