LangChain says it could not import the chromadb package
ImportError: 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.
Fix it fast
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__)"2Match what you see, then jump to its fix
- 1
pip 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
The traceback goes through langchain_community/vectorstores/chroma.pyYou are on the deprecated langchain_community Chroma classFix
- 1
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 chromadb2Fix
Install with the same interpreter that runs the app, ideally inside the project's virtual environment.
python -m pip install chromadb3Verify
The import now works under that interpreter.
python -c "import chromadb; print(chromadb.__file__)"Confirmed by pip.pypa.io
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 Chroma3Verify
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
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:
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- MenuloA restaurant discovery platform in Germany, kept current by a Python ingestion pipeline.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
AI
Azure OpenAI says the API deployment for this resource does not exist
The API deployment for this resource does not exist
Azure OpenAI does not take a model name in the model field.
2 causes, each with a fixAI
Azure OpenAI fails with an SSL certificate verification error
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED]
The client checks the endpoint's certificate against its CA bundle, which is certifi by default.
2 causes, each with a fixAI
Gemini API returns 429 RESOURCE_EXHAUSTED on the free tier
429 RESOURCE_EXHAUSTED
Gemini limits are applied per Google Cloud project, not per API key, so a new key in the same project does not reset anything.
3 causes, each with a fixAI
ChatPromptTemplate is missing the variable agent_scratchpad
Expected: ['agent_scratchpad', 'input']
A tool-calling agent keeps its tool calls and tool results in a prompt slot named agent_scratchpad.
2 causes, each with a fixAI
LangChain no longer exports AgentExecutor from langchain.agents
ImportError: cannot import name 'AgentExecutor' from 'langchain.agents'
LangChain v1 moved legacy classes into a separate package called langchain-classic, and AgentExecutor lives there now.
2 causes, each with a fixAI
ConversationalRetrievalChain cannot be imported from langchain.chains
Importing ConversationalRetrievalChain from langchain.chains isn't working
In LangChain v1 the legacy chains moved out of the langchain package into langchain-classic, so langchain.chains no longer has ConversationalRetrievalChain.
2 causes, each with a fix