{"record":{"id":"c448e9a524dbc735","repo":"chroma-core/chroma","slug":"the-pil-python-package-is-not-installed-please-in-c448e9","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/open_clip_embedding_function.py","lineNumber":58,"sourceCode":"        \"\"\"\n        try:\n            import open_clip\n        except ImportError:\n            raise ValueError(\n                \"The open_clip python package is not installed. Please install it with `pip install open-clip-torch`. https://github.com/mlfoundations/open_clip\"\n            )\n\n        try:\n            self._torch = importlib.import_module(\"torch\")\n        except ImportError:\n            raise ValueError(\n                \"The torch python package is not installed. Please install it with `pip install torch`\"\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        self.model_name = model_name\n        self.checkpoint = checkpoint\n        self.device = device\n\n        model, _, preprocess = open_clip.create_model_and_transforms(\n            model_name=model_name, pretrained=checkpoint\n        )\n        self._model = model\n        self._model.to(device)\n        self._preprocess = preprocess\n        self._tokenizer = open_clip.get_tokenizer(model_name=model_name)\n\n    def _encode_image(self, image: Image) -> Embedding:\n        \"\"\"\n        Encode an image using the Open CLIP model.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/open_clip_embedding_function.py#L40-L76","documentation":"The third import in OpenCLIPEmbeddingFunction.__init__ is PIL.Image (importlib.import_module(\"PIL.Image\")), converted to ValueError with the pip hint on ImportError. Pillow is required because the EF's __call__ opens each image URI with PIL to run open_clip's preprocessing pipeline (resize/crop/normalize) before inference. The import name is PIL.Image but the pip package is pillow — a classic mismatch.","triggerScenarios":"Constructing OpenCLIPEmbeddingFunction() without pillow installed; installing the old/abandoned `pil` or `Pillow` capitalization confusion; pillow uninstalled by a resolver conflict (some libraries pin pillow versions aggressively); headless systems where pillow was trimmed from the base image.","commonSituations":"Minimal Docker images; dependency conflicts with other imaging libraries (e.g. torchvision, matplotlib pulling different pillow pins); using `pip install PIL` (wrong package, use pillow).","solutions":["pip install pillow (the import name PIL comes from the pillow package)","If a version conflict uninstalled it, resolve the pin: pip install 'pillow>=10' alongside your other imaging deps","Verify: python -c \"from PIL import Image; print(Image.__version__)\""],"exampleFix":"// before\nfn = OpenCLIPEmbeddingFunction()  # ValueError: PIL not installed\n\n// after (shell)\npip install pillow\n// then\nfn = OpenCLIPEmbeddingFunction()","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"PIL\") is None:\n    raise SystemExit(\"pillow missing: pip install pillow\")","typeGuard":null,"tryCatchPattern":"try:\n    fn = OpenCLIPEmbeddingFunction()\nexcept ValueError as e:\n    if \"PIL\" in str(e):\n        raise SystemExit(\"Run: pip install pillow\") from e\n    raise","preventionTips":["Remember pip name pillow vs import name PIL","Watch for pillow being uninstalled by resolver conflicts; pin it in the lockfile","Include pillow in image builds that run any image-processing EF"],"tags":["openclip","pillow","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"}