langchain icon indicating copy to clipboard operation
langchain copied to clipboard

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

Open ljhust opened this issue 2 years ago • 2 comments

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

ljhust avatar Feb 13 '23 11:02 ljhust

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.

keviddles avatar Feb 13 '23 15:02 keviddles

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

ljhust avatar Feb 14 '23 08:02 ljhust

should be fixed now

hwchase17 avatar Feb 16 '23 07:02 hwchase17

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

CRortyDG avatar Apr 08 '23 02:04 CRortyDG

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

anton-b avatar Apr 21 '23 10:04 anton-b

update langchain version

pvbang avatar Jul 01 '23 09:07 pvbang

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)
...

Marbyun avatar Aug 31 '23 06:08 Marbyun

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')

manumklm avatar Apr 25 '24 14:04 manumklm

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

Shoupadhyay avatar Jun 15 '24 13:06 Shoupadhyay