chroma
chroma copied to clipboard
Chromadb fails to install on MacOS 13.2.1 (i9) with latest XCode
pip3 install chromadb on MacOS 13 (i9 hardware) fails:
Building wheels for collected packages: hnswlib
Building wheel for hnswlib (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for hnswlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [17 lines of output]
running bdist_wheel
running build
running build_ext
creating var
creating var/folders
creating var/folders/q_
creating var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn
creating var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T
clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c /var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T/tmpq86o7pij.cpp -o var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T/tmpq86o7pij.o -std=c++14
clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c /var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T/tmpkpsz3vsz.cpp -o var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T/tmpkpsz3vsz.o -fvisibility=hidden
building 'hnswlib' extension
creating build
creating build/temp.macosx-10.9-universal2-cpython-311
creating build/temp.macosx-10.9-universal2-cpython-311/python_bindings
clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/private/var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T/pip-build-env-i22faqo5/overlay/lib/python3.11/site-packages/pybind11/include -I/private/var/folders/q_/f5sh90n16hb55w1tz2_s2vqw0000gn/T/pip-build-env-i22faqo5/overlay/lib/python3.11/site-packages/numpy/core/include -I./hnswlib/ -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c ./python_bindings/bindings.cpp -o build/temp.macosx-10.9-universal2-cpython-311/./python_bindings/bindings.o -O3 -march=native -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO=\"0.7.0\" -std=c++14 -fvisibility=hidden
clang: error: the clang compiler does not support '-march=native'
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for hnswlib
Failed to build hnswlib
ERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects
Unfortunately, clang cannot be updated beyond 14.0.0 on non-M1 hardware (related) because it is managed by XCode
Having the same issue
same as well
To confirm, this is on non M1/M2 hardware? So Intel silicon?
correct. i9.
I am not on intel, fwiw -
Same error here, trying to install on a M1 inside a Docker Container.
thanks everyone for reporting
im looking into this, with haste!
@jeffchuber thanks!
In my case, downgrading the Python version in Docker from: python:3.11-slim to python:3.10.10
Solved the installation issue.
There is an issue with 3.11 and compatibility with sentence-transformers which is currently a requirement. https://github.com/chroma-core/chroma/issues/163#issuecomment-1440253969 (though we plan to remove it from a hard req)
I looked inside the hnswlib's setup.py and found that it checks for a HNSWLIB_NO_NATIVE flag...
export HNSWLIB_NO_NATIVE=1
Once that was set, I gather pip install didn't try to use -march=native and installation worked. Hope this helps someone out there...
Hi thanks for finding this. Hnswlib can’t use the native flag on platforms like Apple silicon because sometimes the clang environment doesn’t support that keyword yet. I’ll add this to our troubleshooting guide. Thanks
I looked inside the hnswlib's setup.py and found that it checks for a HNSWLIB_NO_NATIVE flag...
export HNSWLIB_NO_NATIVE=1Once that was set, I gather pip install didn't try to use -march=native and installation worked. Hope this helps someone out there...
This worked for me! Saved my day!
Same! Thank you @dcydrob ... export HNSWLIB_NO_NATIVE=1 works perfectly.
This works! Thank you so much
For me, xcode-select --install worked.
@jeffchuber, @dcydrob, and fellows,
I have installed python 10.10.10 and successfully installed chromadb==0.3.21 on my Apple M2 Max, Ventura 13.3.1 MacOs. I also put this one "export HNSWLIB_NO_NATIVE=1".
But still gives this error "NameError: name 'chromadb' is not defined". I need help please! Thanks
I am using Apple M2 Max, Ventura 13.3.1 MacOs.
None of the recommendations mentioned here were worked for me such as:
- python 10.10.10,
- export HNSWLIB_NO_NATIVE=1
- xcode-select --install
- arch -x86_64 zsh
- %pip install hnswlib==0.6.2
- %pip install chromadb==0.3.15 or newer versions (%pip install hnswlib, %pip install chromadb)
this is the error. though, I have chromadb installed, but it says "chromadb" is not defined. (!conda list | grep "^chromadb">> chromadb 0.3.15)
NotEnoughElementsException Traceback (most recent call last) File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/vectorstores/chroma.py:111, in Chroma.__query_collection(self, query_texts, query_embeddings, n_results, where) 110 try: --> 111 return self._collection.query( 112 query_texts=query_texts, 113 query_embeddings=query_embeddings, 114 n_results=i, 115 where=where, 116 ) 117 except chromadb.errors.NotEnoughElementsException:
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/chromadb/api/models/Collection.py:203, in Collection.query(self, query_embeddings, query_texts, n_results, where, where_document, include) 201 where_document = {} --> 203 return self._client._query( 204 collection_name=self.name, 205 query_embeddings=query_embeddings, 206 n_results=n_results, 207 where=where, 208 where_document=where_document, 209 include=include, 210 )
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/chromadb/api/local.py:247, in LocalAPI._query(self, collection_name, query_embeddings, n_results, where, where_document, include) 238 def _query( 239 self, 240 collection_name, (...) 245 include: Include = ["documents", "metadatas", "distances"], 246 ): --> 247 uuids, distances = self._db.get_nearest_neighbors( 248 collection_name=collection_name, 249 where=where, 250 where_document=where_document, 251 embeddings=query_embeddings, 252 n_results=n_results, 253 ) 255 include_embeddings = "embeddings" in include
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/chromadb/db/clickhouse.py:521, in Clickhouse.get_nearest_neighbors(self, where, where_document, embeddings, n_results, collection_name, collection_uuid) 520 index = self._index(collection_uuid) --> 521 uuids, distances = index.get_nearest_neighbors(embeddings, n_results, ids) 523 return uuids, distances
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/chromadb/db/index/hnswlib.py:228, in Hnswlib.get_nearest_neighbors(self, query, k, ids) 227 if k > self._index_metadata["elements"]: --> 228 raise NotEnoughElementsException( 229 f"Number of requested results {k} cannot be greater than number of elements in index {self._index_metadata['elements']}" 230 ) 232 s2 = time.time()
NotEnoughElementsException: Number of requested results 4 cannot be greater than number of elements in index 1
During handling of the above exception, another exception occurred:
NameError Traceback (most recent call last) Cell In[71], line 1 ----> 1 chain.run('How was the GPT4all model trained?')
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/chains/base.py:238, in Chain.run(self, callbacks, *args, **kwargs)
236 if len(args) != 1:
237 raise ValueError("run supports only one positional argument.")
--> 238 return self(args[0], callbacks=callbacks)[self.output_keys[0]]
240 if kwargs and not args:
241 return self(kwargs, callbacks=callbacks)[self.output_keys[0]]
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/chains/base.py:142, in Chain.call(self, inputs, return_only_outputs, callbacks) 140 except (KeyboardInterrupt, Exception) as e: 141 run_manager.on_chain_error(e) --> 142 raise e 143 run_manager.on_chain_end(outputs) 144 return self.prep_outputs(inputs, outputs, return_only_outputs)
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/chains/base.py:136, in Chain.call(self, inputs, return_only_outputs, callbacks) 130 run_manager = callback_manager.on_chain_start( 131 {"name": self.class.name}, 132 inputs, 133 ) 134 try: 135 outputs = ( --> 136 self._call(inputs, run_manager=run_manager) 137 if new_arg_supported 138 else self._call(inputs) 139 ) 140 except (KeyboardInterrupt, Exception) as e: 141 run_manager.on_chain_error(e)
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:119, in BaseRetrievalQA._call(self, inputs, run_manager) 116 _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager() 117 question = inputs[self.input_key] --> 119 docs = self._get_docs(question) 120 answer = self.combine_documents_chain.run( 121 input_documents=docs, question=question, callbacks=_run_manager.get_child() 122 ) 124 if self.return_source_documents:
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py:181, in RetrievalQA._get_docs(self, question) 180 def _get_docs(self, question: str) -> List[Document]: --> 181 return self.retriever.get_relevant_documents(question)
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/vectorstores/base.py:333, in VectorStoreRetriever.get_relevant_documents(self, query) 331 def get_relevant_documents(self, query: str) -> List[Document]: 332 if self.search_type == "similarity": --> 333 docs = self.vectorstore.similarity_search(query, **self.search_kwargs) 334 elif self.search_type == "mmr": 335 docs = self.vectorstore.max_marginal_relevance_search( 336 query, **self.search_kwargs 337 )
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/vectorstores/chroma.py:171, in Chroma.similarity_search(self, query, k, filter, **kwargs) 154 def similarity_search( 155 self, 156 query: str, (...) 159 **kwargs: Any, 160 ) -> List[Document]: 161 """Run similarity search with Chroma. 162 163 Args: (...) 169 List[Document]: List of documents most similar to the query text. 170 """ --> 171 docs_and_scores = self.similarity_search_with_score(query, k, filter=filter) 172 return [doc for doc, _ in docs_and_scores]
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/vectorstores/chroma.py:217, in Chroma.similarity_search_with_score(self, query, k, filter, **kwargs) 215 else: 216 query_embedding = self._embedding_function.embed_query(query) --> 217 results = self.__query_collection( 218 query_embeddings=[query_embedding], n_results=k, where=filter 219 ) 221 return _results_to_docs_and_scores(results)
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/utils.py:42, in xor_args.
File ~/anaconda3/envs/Langchain/lib/python3.10/site-packages/langchain/vectorstores/chroma.py:117, in Chroma.__query_collection(self, query_texts, query_embeddings, n_results, where) 110 try: 111 return self._collection.query( 112 query_texts=query_texts, 113 query_embeddings=query_embeddings, 114 n_results=i, 115 where=where, 116 ) --> 117 except chromadb.errors.NotEnoughElementsException: 118 logger.error( 119 f"Chroma collection {self._collection.name} " 120 f"contains fewer than {i} elements." 121 ) 122 raise chromadb.errors.NotEnoughElementsException( 123 f"No documents found for Chroma collection {self._collection.name}" 124 )
NameError: name 'chromadb' is not defined
I have the same issues as phdykd. Is there another solution?
Got the same issue here. phdykd
Python 3.9.2 @ Debian 11 x86_64 Linux 5.10.0-22-amd64
$pip freeze | grep chromadb
chromadb==0.3.21
When running my application, it throws me the following exception:
Error recibiendo data desde OpenAI: name 'chromadb' is not defined
The text in spanish is from my exception handling.
@phdykd @schwarbf @dlimon2 For those of you getting the "'chromadb' is not defined" error, that sounds very different from what this thread is about, which is installation of the package failing. Your error message sounds like you haven't imported the chromadb package into the code where it's trying to be accessed. Without seeing more, it's hard to say more.
I am using a Apple M1 with macOS Venture Version 13.3.1. I've tried the following:
- multiple python versions (like 10.10.10)
- set
HNSWLIB_NO_NATIVE=1 arch -x86_64 zsh%pip install hnswlib==0.6.2%pip install chromadb==0.3.15
and I still get this error: Collecting hnswlib>=0.7 (from chromadb>=0.3.10->-r requirements.txt (line 3)) Using cached hnswlib-0.7.0.tar.gz (33 kB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
export HNSWLIB_NO_NATIVE=1
I am also getting this after using export HNSWLIB_NO_NATIVE=1.
This ssue is tracked at https://github.com/chroma-core/chroma/issues/250
It turns out this is due to failing installation of pip install hnswlib
To be clear, the HNSWLIB_NO_NATIVE=1 is specifically for the error OP was having, where hnswlib fails to install bc of:
clang: error: the clang compiler does not support '-march=native'
You should not expect it to help with different sources of failure...
- arch -x86_64 zsh
I have had the same problems. Nothing works. I almost give up to use chroma. I'm using Ventura 13.4 with M1
I'm on Linux Mint, and I'm having this issue, except it just hangs pip
我已收到,感谢你的来信!
I've solved this with Miniconda on an M2 MacBook:
brew install miniforge
conda init zsh
conda activate base
conda install chromadb
On MacOS 13.5 (2020 Intel Core i7), I was encountering same original issue:
× Building wheel for chroma-hnswlib (pyproject.toml) did not run successfully. ... Failed to build chroma-hnswlib
this, alone, did not resolve issue (but may have helped):
export HNSWLIB_NO_NATIVE=1
this did allow install to succeed:
xcode-select --install
我已收到,感谢你的来信!
Closing this out as I think the appropriate solutions have been discussed and documented.