LlamaIndex cannot find LangchainEmbedding in the llama_index package
ImportError: cannot import name 'LangchainEmbedding' from 'llama_index'Short answer
LangchainEmbedding no longer lives at the top of llama_index. It is part of a separate integration package, llama-index-embeddings-langchain, and is imported from llama_index.embeddings.langchain. Install that package into the interpreter that runs your code, then change the import line. Core classes come from llama_index.core.
Fix it fast
1Find out which cause you have
Print which LlamaIndex packages the failing interpreter has. In a notebook, run it in a cell so you see the notebook's own Python.
python -m pip list | grep -i llama2Match what you see, then jump to its fix
- 1
Your code or tutorial says from llama_index import LangchainEmbeddingThe import path is from the old single-package layoutFix - 2
ModuleNotFoundError for llama_index.embeddings.langchain, often in Colab or a second virtual environmentThe integration package is missing from the interpreter that runs the codeFix
- 1
What does the error look like?
ImportError: cannot import name 'LangchainEmbedding' from 'llama_index'
Cause 1 of 2
The import path is from the old single-package layout
1Check
Search the project for the old line. LlamaIndex now splits its code into a core package plus one package per integration, and imports containing core belong to the core package.
grep -rn "LangchainEmbedding" --include=*.py .2Fix
Install the integration package and import the class from its own namespace. It wraps any LangChain Embeddings object.
pip install llama-index-embeddings-langchain
# in Python
from llama_index.embeddings.langchain import LangchainEmbedding
embed_model = LangchainEmbedding(langchain_embeddings=lc_embeddings)3Verify
The import runs without an error and the wrapper returns a vector.
python -c "from llama_index.embeddings.langchain import LangchainEmbedding; print('ok')"Confirmed by developers.llamaindex.ai
Cause 2 of 2
The integration package is missing from the interpreter that runs the code
1Check
Installing llama-index alone does not guarantee every integration. Integrations are separate packages, so list what this exact Python has.
python -m pip show llama-index-embeddings-langchain2Fix
Install it with the same Python that runs the script, then restart the notebook kernel so the new package is picked up. Keep the LangChain side installed too, since you pass it a LangChain embeddings instance.
python -m pip install llama-index-embeddings-langchain3Verify
pip show now prints a version, and the import line works after the restart.
python -m pip show llama-index-embeddings-langchainConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Install every LlamaIndex integration by its own package name and put them all in requirements.txt.
- When copying a tutorial, check its LlamaIndex version first; older posts use import paths that no longer exist.
- Import core classes from llama_index.core and integrations from their own namespaces.
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
LlamaIndex cannot import Ollama from llama_index.llms
ImportError: cannot import name 'Ollama' from 'llama_index.llms' (unknown location)
Since LlamaIndex 0.10, each integration is its own package and the old top-level llama_index.llms path is gone.
3 causes, each with a fixAI
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
LangChain says it could not import the chromadb package
ImportError: Could not import chromadb python package. Please install it with `pip install chromadb`.
The message comes from LangChain's old Chroma class, which cannot import chromadb in the Python that runs your code.
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 fix