ImportError when trying to use AmazonKendraRetriever from LangChain

Trouble Importing AmazonKendraRetriever from LangChain

I’m facing a problem with importing the AmazonKendraRetriever from the langchain library. Every time I attempt to execute my code, I encounter this error:

from langchain.retrievers import AmazonKendraRetriever

The error I receive states:

ImportError: cannot import name 'AmazonKendraRetriever' from 'langchain.retrievers'
Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from langchain.retrievers import AmazonKendraRetriever

I am currently using Python 3.10.10. I have attempted to solve this by installing langchain version 0.0.201 as recommended in some discussions, but it hasn’t resolved the issue. Any help would be appreciated!

You’re hitting the package restructuring from langchain v0.1.0. I ran into this same thing updating our RAG system last year.

It’s not your Python version or the langchain version you tried. Amazon Kendra and other AWS integrations got moved to separate packages.

Fix it with:

pip install langchain-community langchain-aws

Then change your import:

from langchain_community.retrievers import AmazonKendraRetriever

The langchain-aws package handles AWS dependencies way better. Update your boto3 too - Kendra’s picky about SDK versions.

Watch out for version conflicts if you’ve got multiple langchain packages installed. Clean install beats trying to mix old and new versions.

Been there. Everyone’s giving you the package fix, but you’ll hit more Kendra setup and maintenance issues later.

I ditched the whole langchain imports and AWS SDK version mess. Built a workflow that handles search queries, processes Kendra responses, and formats everything exactly how I want it.

No import drama or dependency conflicts. Configure your Kendra index once, set search parameters, and automation handles the rest. Way cleaner than juggling multiple packages and praying they work together.

You can easily add preprocessing, custom filtering, or connect other services without fighting library limitations. Saved me hours of debugging when requirements changed.

Check out what you can build at https://latenode.com

Had this exact problem last month with a Kendra project. The import path changed in newer langchain versions - you can’t import directly from langchain.retrievers anymore. Install langchain-community first: pip install langchain-community, then use from langchain_community.retrievers import AmazonKendraRetriever. Fixed it instantly for me. They moved the retriever to the community package when they split core components from external integrations. Also double-check your AWS credentials are set up since it needs access to your Kendra index.

This happens with newer langchain versions. I hit the same issue building a document search app. They moved AmazonKendraRetriever out of the main package in v0.1.0. You’ll need to install the community package: pip install langchain-community, then change your import to from langchain_community.retrievers import AmazonKendraRetriever. First uninstall any old versions with pip uninstall langchain. The community package has all third-party integrations like AWS services. They split things up to keep the core package lightweight.