langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.22k stars 14.72k forks source link

'from langchain.vectorstores import Chroma' could not find Chroma #1020

Closed ljhust closed 1 year ago

ljhust commented 1 year ago

following doc below: https://langchain.readthedocs.io/en/latest/modules/utils/combine_docs_examples/vectorstores.html from langchain.vectorstores import ElasticVectorSearch, Pinecone, Weaviate, FAISS, Qdrant, Chroma could not find Chroma, as ref to the source code Chroma module has been delayed, please modify the doc correctly

keviddles commented 1 year ago

As a workaround, this seems to work:

from langchain.vectorstores.chroma import Chroma

Not sure why __init__ is not exposing Chroma, as it appears to be imported correctly.

ljhust commented 1 year ago

It is my version: lanchain==0.0.84 and source below there is no Chroma included

image
hwchase17 commented 1 year ago

should be fixed now

CRortyDG commented 1 year ago

App 2066 output: from langchain.vectorstores import Chroma App 2066 output: ImportError: App 2066 output: cannot import name 'Chroma' from 'langchain.vectorstores' (/home/aidesign/virtualenv/groundskeeper/3.7/lib/python3.7/site-packages/langchain/vectorstores/init.py)

This error seems to still be present for me

anton-b commented 1 year ago

App 2066 output: from langchain.vectorstores import Chroma App 2066 output: ImportError: App 2066 output: cannot import name 'Chroma' from 'langchain.vectorstores' (/home/aidesign/virtualenv/groundskeeper/3.7/lib/python3.7/site-packages/langchain/vectorstores/init.py)

This error seems to still be present for me

did you try to bump langchain in your requirements.txt, or take version constraint away and then: pip install langchain --upgrade

Installing collected packages: langchain
  Attempting uninstall: langchain
    Found existing installation: langchain 0.0.58
    Uninstalling langchain-0.0.58:
      Successfully uninstalled langchain-0.0.58
Successfully installed langchain-0.0.146
pvbang commented 1 year ago

update langchain version

Marbyun commented 1 year ago

can someone help me

i get this error

Traceback (most recent call last): File "c:\Users\IvanRivaldo\anaconda3\envs\pytorch\Lib\site-packages\langchain\vectorstores\chroma.py", line 80, in init import chromadb File "c:\Users\IvanRivaldo\anaconda3\envs\pytorch\Lib\site-packages\chromadb__init.py", line 4, in import chromadb.config File "c:\Users\IvanRivaldo\anaconda3\envs\pytorch\Lib\site-packages\chromadb\config.py", line 12, in from pydantic import BaseSettings, validator File "c:\Users\IvanRivaldo\anaconda3\envs\pytorch\Lib\site-packages\pydantic\init.py", line 210, in getattr__ File "c:\Users\IvanRivaldo\anaconda3\envs\pytorch\Lib\site-packages\pydantic_migration.py", line 289, in wrapper pydantic.errors.PydanticImportError: BaseSettings has been moved to the pydantic-settings package. See https://docs.pydantic.dev/2.3/migration/#basesettings-has-moved-to-pydantic-settings for more details.

For further information visit https://errors.pydantic.dev/2.3/u/import-error

this is my code:

fromlangchain.vectorstores import Chroma

....

vectorstore = Chroma.from_texts(texts, embeddings)
...
manumklm commented 4 months ago

After a long workaround i solved the issue like this. override chromadb with pysqlite3-binary Please note that this is applicable for linux only . In window i used python 3.11.5 to solve the issue.

  1. install pysqlite3-binary pip install pysqlite3-binary

  2. Add this in your project code where importing chroma

from langchain.vectorstores.chroma import Chroma sys.modules['sqlite3'] = import('pysqlite3')

Shoupadhyay commented 2 months ago

what about mac ? also i get error 24-06-13 10:14:35.016 Uncaught app exception Traceback (most recent call last): File "/Users/shobhitupadhyay/anaconda3/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script exec(code, module.dict) File "/Users/shobhitupadhyay/Stream/main.py", line 9, in chain = get_few_shot_db_chain() ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shobhitupadhyay/Stream/langchain_helper.py", line 27, in get_few_shot_db_chain vectorstore = Chroma.from_texts(to_vectorize, embeddings, metadatas=few_shots) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shobhitupadhyay/anaconda3/lib/python3.11/site-packages/langchain/vectorstores/chroma.py", line 567, in from_texts chroma_collection = cls( ^^^^ File "/Users/shobhitupadhyay/anaconda3/lib/python3.11/site-packages/langchain/vectorstores/chroma.py", line 125, in init self._collection = self._client.get_or_create_collection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shobhitupadhyay/anaconda3/lib/python3.11/site-packages/chromadb/api/client.py", line 237, in get_or_create_collection even if i removes the metadatas argrument the link it provides is not available