Debug Fix beginner · 3 min read

How to fix LangChain deprecated import langchain.vectorstores

Quick answer
The import path langchain.vectorstores is deprecated. Replace it with langchain_community.vectorstores to fix import errors and ensure compatibility with LangChain v0.2+.
ERROR TYPE code_error
⚡ QUICK FIX
Change your import from from langchain.vectorstores import FAISS to from langchain_community.vectorstores import FAISS.

Why this happens

LangChain reorganized its package structure in v0.2+, moving vectorstore implementations out of the core langchain package into langchain_community. If you use from langchain.vectorstores import FAISS, you will get an ImportError or a deprecation warning because that module no longer exists in the core package.

Typical error output:

ImportError: cannot import name 'FAISS' from 'langchain.vectorstores'
python
from langchain.vectorstores import FAISS

# This import will fail in LangChain v0.2+
output
ImportError: cannot import name 'FAISS' from 'langchain.vectorstores'

The fix

Update your imports to use the new package langchain_community.vectorstores. This reflects the current LangChain v0.2+ structure and resolves the import error.

Example corrected code:

python
from langchain_community.vectorstores import FAISS
from langchain_openai import OpenAIEmbeddings

# Now you can instantiate and use FAISS vectorstore as before
vectorstore = FAISS.from_texts(["Hello world"], OpenAIEmbeddings())
output
No import errors; vectorstore initialized successfully.

Preventing it in production

To avoid breaking changes from LangChain updates:

  • Pin your LangChain version in requirements.txt or pyproject.toml to a stable release.
  • Regularly check the LangChain release notes for breaking changes.
  • Use automated tests to catch import or API changes early.
  • Consider wrapping imports in try-except blocks if supporting multiple LangChain versions.

Key Takeaways

  • Always import vectorstores from langchain_community.vectorstores in LangChain v0.2+.
  • Pin LangChain versions and monitor release notes to avoid breaking changes.
  • Use automated tests to detect deprecated imports early in your CI pipeline.
Verified 2026-04
Verify ↗