{"record":{"id":"951fad2b66ece967","repo":"chroma-core/chroma","slug":"the-ollama-python-package-is-not-installed-please","errorCode":null,"errorMessage":"The ollama python package is not installed. Please install it with `pip install ollama`","messagePattern":"The ollama python package is not installed\\. Please install it with `pip install ollama`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/ollama_embedding_function.py","lineNumber":34,"sourceCode":"    def __init__(\n        self,\n        url: str = \"http://localhost:11434\",\n        model_name: str = DEFAULT_MODEL_NAME,\n        timeout: int = 60,\n    ) -> None:\n        \"\"\"\n        Initialize the Ollama Embedding Function.\n\n        Args:\n            url (str): The Base URL of the Ollama Server (default: \"http://localhost:11434\").\n            model_name (str): The name of the model to use for text embeddings.\n                Defaults to \"chroma/all-minilm-l6-v2-f32\", for available models see https://ollama.com/library.\n            timeout (int): The timeout for the API call in seconds. Defaults to 60.\n        \"\"\"\n        try:\n            from ollama import Client\n        except ImportError:\n            raise ValueError(\n                \"The ollama python package is not installed. Please install it with `pip install ollama`\"\n            )\n\n        self.url = url\n        self.model_name = model_name\n        self.timeout = timeout\n\n        # Adding this for backwards compatibility with the old version of the EF\n        self._base_url = url\n        if self._base_url.endswith(\"/api/embeddings\"):\n            parsed_url = urlparse(url)\n            self._base_url = f\"{parsed_url.scheme}://{parsed_url.netloc}\"\n\n        self._client = Client(host=self._base_url, timeout=timeout)\n\n    def __call__(self, input: Documents) -> Embeddings:\n        \"\"\"\n        Get the embeddings for a list of texts.","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/ollama_embedding_function.py#L16-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["pip install ollama into the same interpreter/venv that runs Chroma (verify with `python -m pip show ollama`)","Add ollama to requirements.txt/pyproject next to chromadb for reproducible environments","If you intentionally run without Ollama, pick a different EF (e.g. DefaultEmbeddingFunction) instead of this one"],"exampleFix":"// before\nfn = OllamaEmbeddingFunction(url=\"http://localhost:11434\", model_name=\"nomic-embed-text\")  # ValueError: package not installed\n\n// after (shell)\npip install ollama\n// then\nfn = OllamaEmbeddingFunction(url=\"http://localhost:11434\", model_name=\"nomic-embed-text\")","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"ollama\") is None:\n    raise SystemExit(\"ollama package missing: pip install ollama\")\nfn = OllamaEmbeddingFunction(url=\"http://localhost:11434\", model_name=\"nomic-embed-text\")","typeGuard":null,"tryCatchPattern":"try:\n    fn = OllamaEmbeddingFunction(url=..., model_name=...)\nexcept ValueError as e:\n    if \"not installed\" in str(e):\n        raise SystemExit(\"Run: pip install ollama\") from e\n    raise","preventionTips":["Pin optional EF deps (ollama) in the same lockfile as chromadb","Run dependency smoke tests in CI that construct every EF you use","Use one interpreter/venv consistently; verify with python -m pip show ollama"],"tags":["ollama","embedding-function","import-error","dependency","chroma"],"backgroundTag":"missing-dependency","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}