ImportError: cannot import name Mistral from mistralai after mixing conda and pip installs

Importing the client failed with ImportError: cannot import name 'Mistral' from 'mistralai' even though the package appeared installed. The reporter had installed mistralai with conda, which gave the old 0.x release, and then with pip, which gave 1.x, and was running the code inside a Jupyter notebook. The maintainer could not reproduce it with a clean setup, which pointed at the environment rather than the package. Restarting the Jupyter kernel so it picked up the pip-installed 1.x package made the import work.

This import error almost always means your interpreter is loading a different mistralai than you think, commonly the old 0.x from conda when pip installed 1.x. Check which Python your notebook kernel uses with sys.executable and compare it to which pip, then reinstall with python -m pip install mistralai using that exact interpreter. Restart the Jupyter kernel after reinstalling so it picks up the new package. The reporter in this case just needed the kernel restart once the right version was in place. Source: https://github.com/mistralai/client-python/issues/211

Source: https://github.com/mistralai/client-python/issues/211