Chromadb Vector database

vectordb = Chroma.from_documents(
documents=splits,
embedding=embedding,
persist_directory=persist_directory
)

ImportError: Could not import chromadb python package. Please install it with pip install chromadb.

getting this Import error, tried multiple versions of chromadb nothing worked for me.

Please use !pip list | grep -i chromadb to grab the version of the library inside the deeplearning.ai notbook.

Actually I was running in local

I’m having the same issue when running local. I also tried installing chromadb several times. The error returns like this:


ModuleNotFoundError Traceback (most recent call last)
File c:\Users(…)\venv\lib\site-packages\langchain_community\vectorstores\chroma.py:81, in Chroma.init(self, collection_name, embedding_function, persist_directory, client_settings, collection_metadata, client, relevance_score_fn)
80 try:
—> 81 import chromadb
82 import chromadb.config

ModuleNotFoundError: No module named ‘chromadb’

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
Cell In[16], line 1
----> 1 vectordb = Chroma.from_documents(
2 documents=splits,
3 embedding=embedding,
4 persist_directory=persist_directory
5 )

File c:\Users(…)\venv\lib\site-packages\langchain_community\vectorstores\chroma.py:778, in Chroma.from_documents(cls, documents, embedding, ids, collection_name, persist_directory, client_settings, client, collection_metadata, **kwargs)
776 texts = [doc.page_content for doc in documents]
777 metadatas = [doc.metadata for doc in documents]
→ 778 return cls.from_texts(
779 texts=texts,
780 embedding=embedding,

87 )
89 if client is not None:
90 self._client_settings = client_settings

ImportError: Could not import chromadb python package. Please install it with pip install chromadb.

1 Like
pip install chromadb==0.3.26

Reference notebook: https://learn.deeplearning.ai/langchain-chat-with-your-data/lesson/4/vectorstores-and-embedding

I am facing the same error. Also, when I am trying to uninstall the chromadb to install it again failing to do so.

I ran into a different error when installing chroma locally, but sharing the solution here in case it helps. The error was:

error: command '/usr/bin/clang' failed with exit code 1
ERROR: Could not build wheels for chroma-hnswlib, which is required to install pyproject.toml-based projects

I was able to install Chroma by running:

export HNSWLIB_NO_NATIVE=1 
pip install chromadb

Once you install it, you can unset the env variable if you want.