Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
AI and LLM integration

LangChain says it could not import the chromadb package

ErrorImportError: Could not import chromadb python package. Please install it with `pip install chromadb`.

Short answer

The message comes from LangChain's old Chroma class, which cannot import chromadb in the Python that runs your code. Install chromadb with python -m pip so it lands in that interpreter. Then move to the maintained langchain-chroma package and import Chroma from langchain_chroma instead.

  • Applies to langchain-chroma 0.1.2 and later, chromadb 1.x, Python 3.10-3.13
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the exact interpreter that runs your script whether it can see chromadb. If this fails, pip installed it somewhere else or not at all.

    python -c "import sys, chromadb; print(sys.executable, chromadb.__file__)"
  2. 2Match what you see, then jump to its fix

    1. 1pip install says 'already satisfied' but the import still fails; common with Jupyter, IDEs and several Python versionschromadb is installed in a different environment than the one running the codeFix
    2. 2The traceback goes through langchain_community/vectorstores/chroma.pyYou are on the deprecated langchain_community Chroma classFix

What does the error look like?

  • ImportError: Could not import chromadb python package. Please install it with `pip install chromadb`.

Cause 1 of 2

chromadb is installed in a different environment than the one running the code

1Check

pip's docs explain that python -m pip runs pip with the interpreter you name, so the package goes where that interpreter looks. A bare pip command can belong to another Python.

which python pip
python -m pip show chromadb

2Fix

Install with the same interpreter that runs the app, ideally inside the project's virtual environment.

python -m pip install chromadb

3Verify

The import now works under that interpreter.

python -c "import chromadb; print(chromadb.__file__)"

Confirmed by pip.pypa.io

Did this fix it?

Cause 2 of 2

You are on the deprecated langchain_community Chroma class

1Check

In langchain-community the Chroma class is marked deprecated, with langchain_chroma.Chroma named as its replacement. LangChain's Chroma page installs langchain-chroma, and that package is what you should import.

grep -rn "vectorstores import Chroma\|langchain_community.vectorstores" --include='*.py' .

2Fix

Install the integration package and change the import.

python -m pip install -U langchain-chroma

# in your code
from langchain_chroma import Chroma

3Verify

The new import and the chromadb import both work.

python -c "from langchain_chroma import Chroma; import chromadb; print('ok')"

Confirmed by docs.langchain.com

Did this fix it?

How do I stop it coming back?

  • Keep dependencies in one requirements file or pyproject and install with python -m pip into a virtual environment.
  • In notebooks, install with the notebook's own interpreter, then restart the kernel.
  • Use langchain-chroma and the langchain_chroma import in new code.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.