ModuleNotFoundError: No module named 'chromadb'
builtins.ModuleNotFoundError: No module named 'chromadb' (ImportError chain in crewai.memory)
Stack trace
Traceback (most recent call last):
File "main.py", line 42, in <module>
crew = Crew(agents=agents, tasks=tasks, memory=True)
File "/site-packages/crewai/crew.py", line 187, in __init__
self._setup_memory(memory_config)
File "/site-packages/crewai/memory/memory_manager.py", line 58, in _setup_memory
from crewai.memory.storage.chroma_storage import ChromaStorage
File "/site-packages/crewai/memory/storage/chroma_storage.py", line 1, in <module>
import chromadb
ModuleNotFoundError: No module named 'chromadb' Why it happens
CrewAI's memory system uses Chroma as its default vector database for storing and retrieving agent conversation history. When you instantiate a Crew with memory=True (or memory=MemoryConfig(type='short_term')), CrewAI attempts to import the chromadb package. If chromadb is not installed in your Python environment, the import fails. This is a common issue because chromadb is an optional dependency: it's not included in the base crewai package to keep installations lightweight.
Detection
Check your environment before initializing a Crew with memory. Use pip list | grep chromadb to verify chromadb is installed. Alternatively, wrap crew initialization in try/except ModuleNotFoundError and log which dependencies are missing before attempting memory operations.
Causes & fixes
chromadb is not installed in your Python environment or virtual environment
Run `pip install chromadb>=0.4.0` in the same virtual environment where crewai is installed. Verify with `python -c 'import chromadb; print(chromadb.__version__)'`
Using a different virtual environment than the one where chromadb is installed (e.g., global Python vs venv)
Activate the correct virtual environment with `source venv/bin/activate` (Linux/Mac) or `venv\Scripts\activate` (Windows), then run `pip install chromadb>=0.4.0`
Enabling memory without specifying a memory type, causing CrewAI to default to Chroma which requires the chromadb package
Either install chromadb, or explicitly disable memory with memory=False, or use memory=MemoryConfig(type='short_term', storage='local') if available in your CrewAI version
chromadb installed but incompatible with your crewai version or Python version
Reinstall with compatible versions: `pip install --upgrade crewai chromadb` or specify exact versions: `pip install crewai>=0.55.0 chromadb>=0.4.24`
Code: broken vs fixed
from crewai import Agent, Task, Crew
import os
# Memory is enabled by default when you set memory=True,
# but chromadb is not installed — this line WILL fail
my_crew = Crew(
agents=[Agent(role='analyst', goal='analyze', backstory='smart')],
tasks=[Task(description='analyze data', expected_output='report', agent=Agent(role='analyst', goal='analyze', backstory='smart'))],
memory=True # <-- BREAKS HERE: ModuleNotFoundError: No module named 'chromadb'
)
my_crew.kickoff(inputs={'data': 'sample'}) from crewai import Agent, Task, Crew
import os
import subprocess
import sys
# FIXED: Ensure chromadb is installed before using memory
try:
import chromadb
except ImportError:
print('Installing chromadb dependency for CrewAI memory...', file=sys.stderr)
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'chromadb>=0.4.24'])
import chromadb
# Now memory=True works because chromadb is available
my_crew = Crew(
agents=[Agent(role='analyst', goal='analyze', backstory='smart')],
tasks=[Task(description='analyze data', expected_output='report', agent=Agent(role='analyst', goal='analyze', backstory='smart'))],
memory=True # <-- FIXED: chromadb is now installed and accessible
)
result = my_crew.kickoff(inputs={'data': 'sample'})
print('Crew execution completed:', result) Workaround
If you cannot install chromadb immediately (e.g., in a locked environment), disable memory by setting memory=False or initialize Crew without the memory parameter. This allows your crew to function without persistent memory storage. Once you can install chromadb, re-enable memory by setting memory=True.
Prevention
In production environments, always include chromadb in your requirements.txt or pyproject.toml if you use CrewAI with memory enabled. Add chromadb>=0.4.24 to your dependency list. Document in your README that memory features require chromadb. Use virtual environments consistently so all developers have identical dependency trees.