{"record":{"id":"ac93e1dae41a342c","repo":"chroma-core/chroma","slug":"the-pil-python-package-is-not-installed-please-in-ac93e1","errorCode":null,"errorMessage":"The PIL python package is not installed. Please install it with `pip install pillow`","messagePattern":"The PIL python package is not installed\\. Please install it with `pip install pillow`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/cohere_embedding_function.py","lineNumber":36,"sourceCode":"\nclass CohereEmbeddingFunction(EmbeddingFunction[Embeddable]):\n    def __init__(\n        self,\n        api_key: Optional[str] = None,\n        model_name: str = \"large\",\n        api_key_env_var: str = \"CHROMA_COHERE_API_KEY\",\n    ):\n        try:\n            import cohere\n        except ImportError:\n            raise ValueError(\n                \"The cohere python package is not installed. Please install it with `pip install cohere`\"\n            )\n\n        try:\n            self._PILImage = importlib.import_module(\"PIL.Image\")\n        except ImportError:\n            raise ValueError(\n                \"The PIL python package is not installed. Please install it with `pip install pillow`\"\n            )\n\n        if api_key is not None:\n            warnings.warn(\n                \"Direct api_key configuration will not be persisted. \"\n                \"Please use environment variables via api_key_env_var for persistent storage.\",\n                DeprecationWarning,\n            )\n        if os.getenv(\"COHERE_API_KEY\") is not None:\n            self.api_key_env_var = \"COHERE_API_KEY\"\n        else:\n            self.api_key_env_var = api_key_env_var\n\n        self.api_key = api_key or os.getenv(self.api_key_env_var)\n        if not self.api_key:\n            raise ValueError(\n                f\"The {self.api_key_env_var} environment variable is not set.\"","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/cohere_embedding_function.py#L18-L54","documentation":"After importing cohere, the constructor separately imports PIL.Image (via importlib) because image inputs are encoded as PNG then base64 data URIs before being sent to Cohere. A missing Pillow install produces this dedicated ValueError, independent of whether cohere itself is present.","triggerScenarios":"Constructing CohereEmbeddingFunction in an environment that has cohere but not Pillow - common when installing cohere alone, since pillow is not a hard Chroma dependency.","commonSituations":"Text-only users hit it because the constructor always imports PIL even if you never send images; slim images that strip pillow; pillow listed only as an optional/dev dependency.","solutions":["pip install pillow, then re-instantiate the embedding function.","Keep pillow pinned next to chromadb and cohere in your dependency manifest.","Check with python -c 'import PIL.Image' in the runtime interpreter."],"exampleFix":"# before\nimport cohere  # ok\nimport PIL.Image  # ModuleNotFoundError -> ValueError: PIL not installed\n\n# after\n# pip install pillow\nfrom chromadb.utils.embedding_functions import CohereEmbeddingFunction\nef = CohereEmbeddingFunction()  # constructs cleanly","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('PIL') is None:\n    raise SystemExit('pip install pillow before using CohereEmbeddingFunction')","typeGuard":null,"tryCatchPattern":"try:\n    ef = CohereEmbeddingFunction()\nexcept ValueError as e:\n    if 'PIL' in str(e) or 'pillow' in str(e):\n        raise SystemExit(f'Dependency missing: {e}') from e\n    raise","preventionTips":["The Cohere EF always imports PIL at construction - install pillow even for text-only use.","Keep pillow pinned next to cohere and chromadb.","Add optional-dependency checks to your app's boot sequence."],"tags":["chroma","cohere","pillow","missing-dependency","embedding-function","multimodal"],"backgroundTag":"missing-python-package","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}