High severity beginner · Fix: 2-5 min

ModuleNotFoundError

builtins.ModuleNotFoundError

What this error means
LangChain raises ModuleNotFoundError because the optional langchain_community package is not installed or not found in the environment.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 3, in <module>
    from langchain_community import SomeCommunityTool
ModuleNotFoundError: No module named 'langchain_community'
QUICK FIX
Run 'pip install langchain-community' in your environment to install the missing module immediately.

Why it happens

This error occurs because langchain_community is an optional extension package that is not included in the core LangChain installation. If your code imports from langchain_community without installing it, Python cannot find the module and raises ModuleNotFoundError.

Detection

Check your import statements for langchain_community and verify if the package is installed in your environment using pip list or pip show langchain-community.

Causes & fixes

1

langchain_community package is not installed in the Python environment

✓ Fix

Install the package via pip using 'pip install langchain-community' to add the missing module.

2

Virtual environment or container does not include langchain_community despite being required

✓ Fix

Ensure your deployment environment or virtualenv includes langchain-community in its requirements.txt or setup scripts.

3

Typo or incorrect import path for langchain_community in the source code

✓ Fix

Verify and correct the import statement to 'from langchain_community import ...' exactly, matching the package name.

Code: broken vs fixed

Broken - triggers the error
python
from langchain_community import SomeCommunityTool  # triggers ModuleNotFoundError if not installed

# rest of your code
Fixed - works correctly
python
import os
from langchain_community import SomeCommunityTool  # fixed by installing langchain-community

# rest of your code

# Make sure to install the package:
# pip install langchain-community
Installed langchain-community package so the import succeeds and ModuleNotFoundError is resolved.

Workaround

If you cannot install langchain-community now, wrap imports in try/except ImportError and disable features that depend on it until the package is installed.

Prevention

Include langchain-community in your project's requirements.txt or environment setup to ensure all dependencies are installed before deployment.

Python 3.9+ · langchain >=0.1.0 · tested on 0.2.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.