Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
AI and LLM integration

LlamaIndex cannot find LangchainEmbedding in the llama_index package

ErrorImportError: 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.

  • Applies to Python 3.12, llama-index-core 0.14, llama-index-embeddings-langchain
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 llama
  2. 2Match what you see, then jump to its fix

    1. 1Your code or tutorial says from llama_index import LangchainEmbeddingThe import path is from the old single-package layoutFix
    2. 2ModuleNotFoundError for llama_index.embeddings.langchain, often in Colab or a second virtual environmentThe integration package is missing from the interpreter that runs the codeFix

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

Did this fix it?

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-langchain

2Fix

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-langchain

3Verify

pip show now prints a version, and the import line works after the restart.

python -m pip show llama-index-embeddings-langchain

Confirmed by raw.githubusercontent.com

Did this fix it?

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:

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 fix

AI

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 fix

Next step

Want this handled for good?

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