{"record":{"id":"277d51c2bd816cdd","repo":"chroma-core/chroma","slug":"the-mistralai-python-package-is-not-installed-ple","errorCode":null,"errorMessage":"The mistralai python package is not installed. Please install it with `pip install mistralai`","messagePattern":"The mistralai python package is not installed\\. Please install it with `pip install mistralai`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/mistral_embedding_function.py","lineNumber":24,"sourceCode":"\n\nclass MistralEmbeddingFunction(EmbeddingFunction[Documents]):\n    def __init__(\n        self,\n        model: str,\n        api_key_env_var: str = \"MISTRAL_API_KEY\",\n    ):\n        \"\"\"\n        Initialize the MistralEmbeddingFunction.\n\n        Args:\n            model (str): The name of the model to use for text embeddings.\n            api_key_env_var (str): The environment variable name for the Mistral API key.\n        \"\"\"\n        try:\n            from mistralai import Mistral\n        except ImportError:\n            raise ValueError(\n                \"The mistralai python package is not installed. Please install it with `pip install mistralai`\"\n            )\n        self.model = model\n        self.api_key_env_var = api_key_env_var\n        self.api_key = os.getenv(api_key_env_var)\n        if not self.api_key:\n            raise ValueError(f\"The {api_key_env_var} environment variable is not set.\")\n        self.client = Mistral(api_key=self.api_key)\n\n    def __call__(self, input: Documents) -> Embeddings:\n        \"\"\"\n        Get the embeddings for a list of texts.\n\n        Args:\n            input (Documents): A list of texts to get embeddings for.\n        \"\"\"\n        if not all(isinstance(item, str) for item in input):\n            raise ValueError(\"Mistral only supports text documents, not images\")","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/mistral_embedding_function.py#L6-L42","documentation":"MistralEmbeddingFunction lazily imports mistralai.Mistral in __init__ and converts ImportError into this ValueError. mistralai is optional in chromadb installs; the client is needed to call Mistral's embeddings endpoint. The failure occurs at construction, before any network activity.","triggerScenarios":"MistralEmbeddingFunction(model='mistral-embed') in an env without the package; fresh venv after `pip install chromadb`; a broken mistralai install whose own dependencies (httpx, pydantic) failed to resolve.","commonSituations":"New integrations following Mistral embedding tutorials; minimal Docker images; dependency conflicts where pip backtracked and removed mistralai.","solutions":["pip install mistralai","Verify the import: python -c \"from mistralai import Mistral; print('ok')\"","Pin mistralai in requirements to survive resolver pruning"],"exampleFix":"# before\nfrom chromadb.utils.embedding_functions import MistralEmbeddingFunction\nef = MistralEmbeddingFunction(model=\"mistral-embed\")  # ValueError\n\n# after\n# pip install mistralai\nimport importlib.util\nif importlib.util.find_spec(\"mistralai\") is None:\n    raise SystemExit(\"pip install mistralai\")\nef = MistralEmbeddingFunction(model=\"mistral-embed\")","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"mistralai\") is None:\n    raise SystemExit(\"Mistral EF needs: pip install mistralai\")\n\nfrom chromadb.utils.embedding_functions import MistralEmbeddingFunction\nef = MistralEmbeddingFunction(model=\"mistral-embed\")","typeGuard":null,"tryCatchPattern":"try:\n    ef = MistralEmbeddingFunction(model=\"mistral-embed\")\nexcept ValueError as e:\n    if \"mistralai\" in str(e):\n        raise RuntimeError(\"pip install mistralai\") from e\n    raise","preventionTips":["Pin mistralai in the lockfile beside chromadb","Add `from mistralai import Mistral` to CI smoke tests for the runtime interpreter","Watch for pip resolver downgrades that remove mistralai when other AI packages conflict"],"tags":["python","dependency","pip","mistralai","optional-import"],"backgroundTag":"missing-optional-dependency","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}