{"record":{"id":"791d1d156c1a0539","repo":"chroma-core/chroma","slug":"the-cohere-python-package-is-not-installed-please","errorCode":null,"errorMessage":"The cohere python package is not installed. Please install it with `pip install cohere`","messagePattern":"The cohere python package is not installed\\. Please install it with `pip install cohere`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/cohere_embedding_function.py","lineNumber":29,"sourceCode":"import numpy as np\nfrom chromadb.utils.embedding_functions.schemas import validate_config_schema\nimport base64\nimport io\nimport importlib\nimport warnings\n\n\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\"","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/cohere_embedding_function.py#L11-L47","documentation":"Chroma keeps provider SDKs optional; CohereEmbeddingFunction imports cohere lazily in __init__ and raises this ValueError when the import fails. Nothing about your Chroma usage or credentials is wrong - the constructor simply cannot build cohere.Client without the package.","triggerScenarios":"CohereEmbeddingFunction(model_name=...) constructed in an interpreter where the cohere distribution is missing - fresh venv, pruned container image, stale lockfile.","commonSituations":"A teammate adds the Cohere embedding function without updating requirements; CI cache built before cohere was needed; different venv between IDE and runtime.","solutions":["pip install cohere in the environment that runs Chroma, then retry construction.","Pin cohere in requirements.txt/pyproject.toml so installs stay reproducible.","Verify with python -c 'import cohere' from the same interpreter you run Chroma with."],"exampleFix":"# before\nfrom chromadb.utils.embedding_functions import CohereEmbeddingFunction\nef = CohereEmbeddingFunction()  # ValueError: cohere not installed\n\n# after\n# pip install cohere\nfrom chromadb.utils.embedding_functions import CohereEmbeddingFunction\nef = CohereEmbeddingFunction(model_name='embed-english-v3.0')","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('cohere') is None:\n    raise SystemExit('pip install cohere before using CohereEmbeddingFunction')","typeGuard":null,"tryCatchPattern":"try:\n    from chromadb.utils.embedding_functions import CohereEmbeddingFunction\n    ef = CohereEmbeddingFunction()\nexcept ValueError as e:\n    if 'cohere' in str(e):\n        raise SystemExit(f'Dependency missing: {e}') from e\n    raise","preventionTips":["Pin cohere (and pillow) in the same manifest as chromadb.","Smoke-test provider imports in CI using the production image.","Check imports in the runtime interpreter, not your editor's venv."],"tags":["chroma","cohere","missing-dependency","embedding-function"],"backgroundTag":"missing-python-package","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}