chroma: [Bug]: Chromadb import error. Dependency issue: Install pydantic-settings package
What happened?
What happened? There was a PydanticImportError when trying to import chromadb. The error occurred because the BaseSettings class has been moved to the pydantic-settings package.
What did you expect to happen? I expected to import chromadb successfully without any errors.
Versions
Python 3.11.3
Relevant log output
import chromadb
---------------------------------------------------------------------------
PydanticImportError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import chromadb
File G:\RajArun\os\chroma\chromaenv\Lib\site-packages\chromadb\__init__.py:1
----> 1 import chromadb.config
      2 import logging
      3 from chromadb.telemetry.events import ClientStartEvent
File G:\RajArun\os\chroma\chromaenv\Lib\site-packages\chromadb\config.py:1
----> 1 from pydantic import BaseSettings
      2 # from pydantic_settings import BaseSettings
      3 from typing import Optional, List, Any, Dict, TypeVar, Set, cast, Iterable, Type
File G:\RajArun\os\chroma\chromaenv\Lib\site-packages\pydantic\__init__.py:206, in __getattr__(attr_name)
    204 dynamic_attr = _dynamic_imports.get(attr_name)
    205 if dynamic_attr is None:
--> 206     return _getattr_migration(attr_name)
    208 from importlib import import_module
    210 module = import_module(_dynamic_imports[attr_name], package=__package__)
File G:\RajArun\os\chroma\chromaenv\Lib\site-packages\pydantic\_migration.py:279, in getattr_migration.<locals>.wrapper(name)
    277     return import_string(DEPRECATED_MOVED_IN_V2[import_path])
    278 if import_path == 'pydantic:BaseSettings':
--> 279     raise PydanticImportError(
    280         '`BaseSettings` has been moved to the `pydantic-settings` package. '
    281         f'See https://docs.pydantic.dev/{VERSION}/migration/#basesettings-has-moved-to-pydantic-settings '
    282         'for more details.'
    283     )
    284 if import_path in REMOVED_IN_V2:
    285     raise PydanticImportError(f'`{import_path}` has been removed in V2.')
PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.0.2/migration/#basesettings-has-moved-to-pydantic-settings for more details.
For further information visit https://errors.pydantic.dev/2.0.2/u/import-error
About this issue
- Original URL
 - State: closed
 - Created a year ago
 - Reactions: 11
 - Comments: 15 (3 by maintainers)
 
Commits related to this issue
- Fix for #774 — committed to chroma-core/chroma by HammadB a year ago
 - add verison range for pydantic (#799) [dont hard pin to ](https://github.com/chroma-core/chroma/issues/774) jump to pydantic v2 we dont want to go there yet so we pinned to 1.9, but langchian use... — committed to chroma-core/chroma by jeffchuber a year ago
 
Downgrading to an even older version of pydantic seems to do the trick (as far as workarounds go):
pip install pydantic==1.9.0Python 3.9 installed with conda also got this err.
update: downgrade package
pydanticfrom2.0.2to2.0works fine for me.We are looking into this, thanks everyone!
FastAPI recently released v0.100.0 where they started using Pydantic v2, which does not work with ChromaDB. Installing
fastapi==0.99.1fixed the issue for me.A short-term fix could be setting the FastAPI dependency in ChromaDB to
fastapi >=0.85.1, <=0.99.1. Settingpydantic >=1.9 , <=1.10.11might also do the trick.hey @husy8 this solution doesn’t works for me, and I’m using the same version.
Thank you for the quick fix! Love your product - keep up the good work!
Hi, I have the same issue that chromadb is using pydantic 1.10.12 but it clash with elevenlabs which use pydantic 2.30. Beside chromadb I use gradio and langchain. I see that gradio is using fastapi also… How did u solve it?
For those langchain users - chroma is cutting a new release momentarily to fix the pydantic version conflict - https://github.com/chroma-core/chroma/pull/799