Chroma/LangChain: 'NoneType' object has no attribute 'info'
Following on from a blog post that I wrote yesterday about doing similarity search with ChromaDB, I noticed an odd error message being printed as the script was exiting. In this blog post, we’ll explore what was going on.
To recap, I have the following code to find chunks of YouTube transcripts that are most similar to an input query:
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.vectorstores import Chroma
hf_embeddings = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
store = Chroma(collection_name="transcript", persist_directory="db", embedding_function=hf_embeddings)
result = store.similarity_search("Who is Tim Berglund?", top_n=2)
for row in result:
print(row)
When I run this script by typing python test_chroma.py
, after the similar documents are printed, I get the following exception:
Exception ignored in: <function PersistentDuckDB.__del__ at 0x2abfe39c0>
Traceback (most recent call last):
File "/Users/markhneedham/projects/docs-bot/env/lib/python3.11/site-packages/chromadb/db/duckdb.py", line 445, in __del__
AttributeError: 'NoneType' object has no attribute 'info'
I came across the following GitHub thread that was discussing the issue and one suggested fix was to set store = None
at the end of the script:
store = None
This did indeed work, but further down the thread it was suggested that the bug is fixed in the latest version of Chroma. I checked my version:
pip freeze | grep chroma
chromadb==0.3.21
A quick check on PyPi revealed that the latest version is actually 0.3.26, so let’s update our version:
pip install --upgrade chromadb
Let’s check our version:
pip freeze | grep chroma
chromadb==0.3.26
If I delete the store = None
line and re-run the script again, the issue has been fixed and I don’t get an error message.
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.