sqliteinformation-retrievallangchainchromadb

Chromadb + Langchain with SentenceTransformerEmbeddingFunction throwing sqlite3 >= 3.35.0 error, despite sqlite3 3.43.0 being available


I have been trying to use

with SentenceTransformerEmbeddingFunction as shown in the snippet below.

from langchain.vectorstores import Chroma
from chromadb.utils import embedding_functions

# other imports
embedding = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")

However, it throws the following error.

RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.

Funfact is I do have the required sqlite3 (3.43.0) available which I can validate using the command sqlite3 --version.

Would appreciate any help. Thank you.


Solution

  • The error message results from importing chromadb in Python:

    >>> import chromadb
    [...]
    RuntimeError: Your system has an unsupported version of sqlite3. Chroma requires sqlite3 >= 3.35.0.
    Please visit https://docs.trychroma.com/troubleshooting#sqlite to learn how to upgrade.
    

    A workaround is suggested through the above url and the informative source code of Chroma. First

    $ pip install pysqlite3-binary 
    

    Then, in Python:

    >>> import pysqlite3
    >>> import sys
    >>> sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
    >>> import chromadb
    >>>
    

    which should now not produce any errors.

    Fun fact:

    $ sqlite3 --version
    3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837balt1
    

    while at the same time, continuing at the above Python console:

    >>> import sqlite3
    >>> sqlite3.sqlite_version
    '3.43.1'