langchain
langchain copied to clipboard
"No module named 'chromadb'" — add chromadb as dependency?
Trying to follow the guides:
- https://langchain.readthedocs.io/en/latest/modules/indexes/getting_started.html
- https://langchain.readthedocs.io/en/latest/modules/indexes/vectorstore_examples/chroma.html
But when I run:
db = Chroma.from_documents(texts, embeddings)
I get:
ModuleNotFoundError Traceback (most recent call last)
File ~/Library/Caches/pypoetry/virtualenvs/docs-bot-z8dlOdVH-py3.10/lib/python3.10/site-packages/langchain/vectorstores/chroma.py:40, in Chroma.__init__(self, collection_name, embedding_function, persist_directory)
39 try:
---> 40 import chromadb
41 import chromadb.config
ModuleNotFoundError: No module named 'chromadb'
In my Poetry dependencies, I only had langchain
and openai
.
I'd suggest adding a line somewhere in the docs that this is an optional dependency and should be installed?
Once I do:
poetry add chromadb
It works.
Interestingly I did not hit this exception path:
https://github.com/hwchase17/langchain/blob/4b5e850361bd4b47ac739748232d696deac79eaf/langchain/vectorstores/chroma.py#L32-L46
Using v0.0.98 within a Jupyter notebook.
Even though I have installed chromadb using pip install chromadb
but error still persists
Is their any underlying issue ,version issue or any other ?
Can't make it work
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma
embeddings= OpenAIEmbeddings(openai_api_key=os.environ['OPENAI_API_KEY'])
docsearch= Chroma.from_documents(texts, embeddings)
Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.10/site-packages/langchain/vectorstores/chroma.py", line 62, in init import chromadb ModuleNotFoundError: No module named 'chromadb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/textToQuery.py", line 22, in pip install chromadb
Make sure that it's installed in the same site packages directory. You may have used a different version of pip from a different python environment.
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
I don't think so it's a pip problem.
I have noticed that during pip install chromadb
, torch process gets killed maybe memory issue.
with this pip install torch --no-cache-dir
What's the chromadb package size?
This is the size:
~/Library/Caches/pypoetry/virtualenvs/docs-bot-z8dlOdVH-py3.10
➜ du -hs lib/python3.10/site-packages/chromadb/
376K lib/python3.10/site-packages/chromadb/
~/Library/Caches/pypoetry/virtualenvs/docs-bot-z8dlOdVH-py3.10
➜ du -hs lib/python3.10/site-packages/chromadb-0.3.10.dist-info
32K lib/python3.10/site-packages/chromadb-0.3.10.dist-info
For me using the following pyproject.toml
was enough, using Poetry:
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = [""]
readme = "README.md"
packages = [{include = "test"}]
[tool.poetry.dependencies]
python = "^3.10,<3.11"
langchain = "^0.0.98"
openai = "^0.27.0"
chromadb = "^0.3.10"
[tool.poetry.group.dev.dependencies]
flake8 = "^6.0.0"
mypy = "^1.0.1"
isort = "^5.12.0"
jupyter = "^1.0.0"
notebook = "^6.5.2"
black = "^23.1.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Then run poetry install
. I generally prefer to use Poetry over user or system library installations.
(Make sure to update to the most recent version of the packages; the above are a bit outdated.)
Thanks, Well my main issue was memory. With combination of larger instance and poetry ,I am able to resolve my problem.
Thanks, Well my main issue was memory. With combination of larger instance and poetry ,I am able to resolve my problem.
Can you please help me out with how you took care of the situation. I am also facing the same issue...will be really helpful if you could elaborate the steps
Did you restart the terminal after the installation. try that it worked for me.
Hi everyone, this is how you can fix this error.
Did you restart the terminal after the installation? I have tried lot of different combination like install with pip, conda etc but it solved with just restarting kernel
After restart it worked for me
Close this issue for now.
I will close this issue once the chromadb dependency is properly documented. I'm not sure if this has been done in the meantime.
im getting below error for chroma db
pip install chromadb
Using cached exceptiongroup-1.1.3-py3-none-any.whl (14 kB)
Building wheels for collected packages: chroma-hnswlib
Building wheel for chroma-hnswlib (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for chroma-hnswlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
running bdist_wheel
running build
running build_ext
building 'hnswlib' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for chroma-hnswlib
Failed to build chroma-hnswlib
ERROR: Could not build wheels for chroma-hnswlib, which is required to install pyproject.toml-based projects
I found this was a version mismatch - langchain expected version 1.5.6. Pinning "chromadb": "1.5.6" in my package.json sorted the issue in my node project, i assume you will need to just align the version in python as well :)
In my case, it is because I named a file with chromadb.py
. Python tries to import from this file instead of installed package.
I solved it after renaming the file.
Hope it help people new to python.
Restart the terminal.It worked for me
chromadb
refer this link for solution: https://stackoverflow.com/questions/64261546/how-to-solve-error-microsoft-visual-c-14-0-or-greater-is-required-when-inst
Tho I installed chromadb, still have this issue pls help anyone