{"record":{"id":"76322fecf7f14454","repo":"chroma-core/chroma","slug":"the-pil-python-package-is-not-installed-please-in-76322f","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/roboflow_embedding_function.py","lineNumber":64,"sourceCode":"                DeprecationWarning,\n            )\n        if os.getenv(\"ROBOFLOW_API_KEY\") is not None:\n            self.api_key_env_var = \"ROBOFLOW_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.\"\n            )\n\n        self.api_url = api_url\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        self._httpx = importlib.import_module(\"httpx\")\n\n    def __call__(self, input: Embeddable) -> Embeddings:\n        \"\"\"\n        Generate embeddings for the given documents or images.\n\n        Args:\n            input: Documents or images to generate embeddings for.\n\n        Returns:\n            Embeddings for the documents or images.\n        \"\"\"\n        embeddings = []\n\n        for item in input:","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/roboflow_embedding_function.py#L46-L82","documentation":"RoboflowEmbeddingFunction.__init__ imports PIL.Image via importlib.import_module and converts ImportError into this ValueError. Pillow is an optional dependency (needed to normalize/serialize images before POSTing them to the Roboflow inference API), so a bare chromadb install lacks it and construction fails — but only after the API-key check passes, which is why it can appear 'later' than expected.","triggerScenarios":"Building RoboflowEmbeddingFunction in an environment without pillow installed: importlib.import_module(\"PIL.Image\") raises ImportError, which the except clause re-raises as ValueError. Note the constructor imports httpx right after, so a missing httpx surfaces as a different (unwrapped) ImportError.","commonSituations":"Server/slim Docker images (python:3.x-slim) where pillow's libjpeg/zlib system libraries are absent; requirements lists chromadb but not pillow; upgrading Python versions where an old pillow wheel breaks and the package silently disappears; embedding images (not text) is the first code path that actually needs PIL.","solutions":["pip install pillow into the running environment and add it to requirements.txt/pyproject.","On slim Docker images also install the native image libs if pillow wheels fail: apt-get install -y libjpeg-dev zlib1g-dev before pip install pillow.","Confirm you are installing into the same interpreter: python -m pip install pillow.","Quick sanity check before constructing: importlib.util.find_spec(\"PIL\") should not be None."],"exampleFix":"// before\nref = RoboflowEmbeddingFunction(api_key=...)  # ValueError: The PIL python package is not installed. Please install it with `pip install pillow`\n\n# after\n# shell: pip install pillow\nimport importlib.util\nif importlib.util.find_spec(\"PIL\") is None:\n    raise RuntimeError(\"Run: pip install pillow\")\nref = RoboflowEmbeddingFunction(api_key_env_var=\"ROBOFLOW_API_KEY\")","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"PIL\") is None:\n    raise RuntimeError(\"Pillow missing — run: pip install pillow\")\n\nref = RoboflowEmbeddingFunction(api_key_env_var=\"ROBOFLOW_API_KEY\")","typeGuard":"import importlib.util\n\ndef pillow_available() -> bool:\n    return importlib.util.find_spec(\"PIL\") is not None","tryCatchPattern":"try:\n    ref = RoboflowEmbeddingFunction()\nexcept ValueError as e:\n    if \"PIL\" in str(e):\n        raise RuntimeError(\"Install image deps: pip install pillow\") from e\n    raise","preventionTips":["Add pillow (and httpx) to your dependency manifest the moment you use image embeddings.","On slim Docker bases, install libjpeg/zlib system libs before pip installing pillow.","Add a find_spec(\"PIL\") check to app startup when image ingestion is enabled."],"tags":["roboflow","pillow","dependency","import","pip","chroma"],"backgroundTag":"missing-python-dependency","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}