chroma
chroma copied to clipboard
[Bug]: AttributeError: module 'numpy.typing' has no attribute 'NDArray'
What happened?
I have installed the below packages in my code:
!pip install langchain
!pip install huggingface_hub
!pip install sentence_transformers
!pip install unstructured
!pip install chromadb
!pip install Cython
!pip install tiktoken
!pip install unstructured[local-inference]
And I'm trying to run the example code from the documentation:
import chromadb
# setup Chroma in-memory, for easy prototyping. Can add persistence easily!
client = chromadb.Client()
# Create collection. get_collection, get_or_create_collection, delete_collection also available!
collection = client.create_collection("all-my-documents")
# Add docs to the collection. Can also update and delete. Row-based API coming soon!
collection.add(
documents=["This is document1", "This is document2"], # we handle tokenization, embedding, and indexing automatically. You can skip that and add your own embeddings as well
metadatas=[{"source": "notion"}, {"source": "google-docs"}], # filter on these!
ids=["doc1", "doc2"], # unique for each doc
)
# Query/search 2 most similar results. You can also .get by id
results = collection.query(
query_texts=["This is a query document"],
n_results=2,
# where={"metadata_field": "is_equal_to_this"}, # optional filter
# where_document={"$contains":"search_string"} # optional filter
)
Please refer to the log output. There seems to be some issue with either numpy or chroma library. This is run as of today, and most of the people might be facing the similar issue. Kindly fix this issue.
Versions
Chroma: 0.3.21 numpy: 1.22.4 Python: 3.9.5 MacOS: Ventura 13.3 Databricks: LTS 11.3, 9.1
Relevant log output
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<command-815074195011808> in <cell line: 3>()
1 import chromadb
2 # setup Chroma in-memory, for easy prototyping. Can add persistence easily!
----> 3 client = chromadb.Client()
4
5 # Create collection. get_collection, get_or_create_collection, delete_collection also available!
/local_disk0/.ephemeral_nfs/envs/pythonEnv-5cdd801c-d64b-4962-ab12-59486d0241a8/lib/python3.9/site-packages/chromadb/__init__.py in Client(settings)
79 elif setting == "local":
80 logger.info("Running Chroma using direct local API.")
---> 81 import chromadb.api.local
82
83 return chromadb.api.local.LocalAPI(settings, get_db(settings), telemetry_client)
/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
172
173 is_root_import = thread_local._nest_level == 1
/local_disk0/.ephemeral_nfs/envs/pythonEnv-5cdd801c-d64b-4962-ab12-59486d0241a8/lib/python3.9/site-packages/chromadb/api/local.py in <module>
6
7 from chromadb.api import API
----> 8 from chromadb.db import DB
9 from chromadb.api.types import (
10 Documents,
/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
172
173 is_root_import = thread_local._nest_level == 1
/local_disk0/.ephemeral_nfs/envs/pythonEnv-5cdd801c-d64b-4962-ab12-59486d0241a8/lib/python3.9/site-packages/chromadb/db/__init__.py in <module>
6
7
----> 8 class DB(ABC):
9 @abstractmethod
10 def __init__(self):
/local_disk0/.ephemeral_nfs/envs/pythonEnv-5cdd801c-d64b-4962-ab12-59486d0241a8/lib/python3.9/site-packages/chromadb/db/__init__.py in DB()
101 def get_nearest_neighbors(
102 self, collection_name, where, embeddings, n_results, where_document
--> 103 ) -> Tuple[List[List[UUID]], npt.NDArray]:
104 pass
105
AttributeError: module 'numpy.typing' has no attribute 'NDArray'
Please refer to the log output. There seems to be some issue with either numpy or chroma library. This is run as of today, and most of the people might be facing the similar issue. Kindly fix this issue.
Hm - sorry about this, I think we may not be pinned to the right version of numpy. Can you upgrade numpy in your env and try again?
facing the same issue using numpy version 1.25.0.. any solution to this?
@shahfasal this type has been removed from this line and we will release it on Monday
Closing this issue as it appears it has been resolved. Please feel free to re-open it if it comes up again.
what is the resolution? I am facing the same issue.
running into the same issue
what is the resolution?
Faced the same issue
AttributeError: module 'numpy.typing' has no attribute 'NDArray'
Resolved by downgrading to numpy<2.0.0