{"record":{"id":"50955b82eb1fe540","repo":"chroma-core/chroma","slug":"the-open-clip-python-package-is-not-installed-ple","errorCode":null,"errorMessage":"The open_clip python package is not installed. Please install it with `pip install open-clip-torch`. https://github.com/mlfoundations/open_clip","messagePattern":"The open_clip python package is not installed\\. Please install it with `pip install open-clip-torch`\\. https://github\\.com/mlfoundations/open_clip","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/open_clip_embedding_function.py","lineNumber":44,"sourceCode":"        model_name: str = \"ViT-B-32\",\n        checkpoint: str = \"laion2b_s34b_b79k\",\n        device: Optional[str] = \"cpu\",\n    ) -> None:\n        \"\"\"\n        Initialize the OpenCLIPEmbeddingFunction.\n\n        Args:\n            model_name (str, optional): The name of the model to use for embeddings.\n                Defaults to \"ViT-B-32\".\n            checkpoint (str, optional): The checkpoint to use for the model.\n                Defaults to \"laion2b_s34b_b79k\".\n            device (str, optional): The device to use for computation.\n                Defaults to \"cpu\".\n        \"\"\"\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","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/open_clip_embedding_function.py#L26-L62","documentation":"OpenCLIPEmbeddingFunction.__init__ does `import open_clip` and converts ImportError into ValueError pointing at `pip install open-clip-torch`. This EF embeds images and text into a shared vector space using mlfoundations' open_clip (default model ViT-B-32, checkpoint laion2b_s34b_b79k), so the package — and its heavy friends torch and pillow — must be installed before construction. The import is deferred so plain chromadb installs stay lightweight.","triggerScenarios":"Constructing OpenCLIPEmbeddingFunction() without `pip install open-clip-torch`; venv/interpreter mismatch (open-clip-torch installed for a different Python); installing `open_clip_torch` under a different name/scope (e.g. only in a notebook kernel's env, not the app's env).","commonSituations":"Prototyping in a notebook (where it works) then running a script in another env (where it doesn't); Docker images that exclude GPU/CV dependencies to slim down; CI caches that skip optional deps.","solutions":["pip install open-clip-torch (note the package name has hyphens; the import name is open_clip)","Verify in the same interpreter: python -c \"import open_clip; print(open_clip.__version__)\"","Add open-clip-torch, torch, and pillow to your lockfile together, since this EF requires all three"],"exampleFix":"// before\nfn = OpenCLIPEmbeddingFunction()  # ValueError: open_clip not installed\n\n// after (shell)\npip install open-clip-torch\n// then\nfn = OpenCLIPEmbeddingFunction()","handlingStrategy":"validation","validationCode":"import importlib.util\nmissing = [m for m in (\"open_clip\", \"torch\", \"PIL\") if importlib.util.find_spec(m) is None]\nif missing:\n    raise SystemExit(f\"OpenCLIP EF needs: pip install open-clip-torch torch pillow (missing: {missing})\")\nfn = OpenCLIPEmbeddingFunction()","typeGuard":null,"tryCatchPattern":"try:\n    fn = OpenCLIPEmbeddingFunction()\nexcept ValueError as e:\n    if \"open_clip\" in str(e):\n        raise SystemExit(\"Run: pip install open-clip-torch\") from e\n    raise","preventionTips":["Install the trio (open-clip-torch, torch, pillow) together in the app environment","Construct every EF your app uses during CI smoke tests","Verify with python -c \"import open_clip\" in the deploy pipeline"],"tags":["openclip","embedding-function","import-error","dependency","multimodal","chroma"],"backgroundTag":"missing-dependency","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}