High severity beginner · Fix: 2-5 min

ModuleNotFoundError

ModuleNotFoundError: No module named 'haystack.document_stores.in_memory'

What this error means
This error occurs when the Haystack InMemoryDocumentStore class or module cannot be found due to missing or incorrect imports or package installation.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 5, in <module>
    from haystack.document_stores import InMemoryDocumentStore
ModuleNotFoundError: No module named 'haystack.document_stores.in_memory'
QUICK FIX
Ensure farm-haystack is installed and import InMemoryDocumentStore from haystack.document_stores exactly.

Why it happens

Haystack's InMemoryDocumentStore class is either not installed or the import path has changed in newer versions. This error typically happens if the haystack package is not installed correctly or if the import statement uses an outdated or incorrect module path.

Detection

Check your import statements and verify that the haystack package is installed in your environment. Use pip list or pip show farm-haystack to confirm installation before running the code.

Causes & fixes

1

Haystack package is not installed in the Python environment

✓ Fix

Install Haystack using pip: pip install farm-haystack to ensure all modules including InMemoryDocumentStore are available.

2

Incorrect import path for InMemoryDocumentStore due to version changes

✓ Fix

Update the import statement to 'from haystack.document_stores import InMemoryDocumentStore' as per the latest Haystack documentation.

3

Using an outdated Haystack version where InMemoryDocumentStore was in a different module

✓ Fix

Upgrade Haystack to a recent version (>=1.0.0) where InMemoryDocumentStore is available under haystack.document_stores.

Code: broken vs fixed

Broken - triggers the error
python
from haystack.document_stores.in_memory import InMemoryDocumentStore  # causes ModuleNotFoundError

store = InMemoryDocumentStore()
print("Store initialized")
Fixed - works correctly
python
import os
from haystack.document_stores import InMemoryDocumentStore  # fixed import path

store = InMemoryDocumentStore()
print("Store initialized")
Corrected the import path to 'haystack.document_stores' which is the valid module containing InMemoryDocumentStore in current Haystack versions.

Workaround

If upgrading or reinstalling is not possible, manually check the installed haystack package directory for InMemoryDocumentStore location and adjust import paths accordingly.

Prevention

Always verify the Haystack version and consult official docs for import paths after upgrades to avoid module not found errors.

Python 3.7+ · farm-haystack >=1.0.0 · tested on 1.14.0
Verified 2026-04
Verify ↗

Community Notes

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