crewAIInc/crewAI · error · ImportError
The 'tavily-python' package is required to use the TavilySea
Error message
The 'tavily-python' package is required to use the TavilySearchTool. Please install it with: uv add tavily-python
What it means
TavilySearchTool requires the optional 'tavily-python' package. When it is missing and you decline the interactive offer to auto-install it (click.confirm returns False), the constructor raises ImportError with the uv add command to run.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py:149
"The 'tavily-python' package is required. 'click' and 'subprocess' are also needed to assist with installation if the package is missing. "
"Please install 'tavily-python' manually (e.g., 'pip install tavily-python') and ensure 'click' and 'subprocess' are available."
) from e
if click.confirm(
"You are missing the 'tavily-python' package, which is required for TavilySearchTool. Would you like to install it?"
):
try:
subprocess.run(["uv", "add", "tavily-python"], check=True) # noqa: S607
raise ImportError(
"'tavily-python' has been installed. Please restart your Python application to use the TavilySearchTool."
)
except subprocess.CalledProcessError as e:
raise ImportError(
f"Attempted to install 'tavily-python' but failed: {e}. "
f"Please install it manually to use the TavilySearchTool."
) from e
else:
raise ImportError(
"The 'tavily-python' package is required to use the TavilySearchTool. "
"Please install it with: uv add tavily-python"
)
def _run(
self,
query: str,
) -> str:
"""Synchronously performs a search using the Tavily API.
Content of each result is truncated to `max_content_length_per_result`.
Args:
query: The search query string.
Returns:
A JSON string containing the search results with truncated content.
"""
if not self.client:View on GitHub (pinned to 754d7323be)
Solutions
- Run: uv add tavily-python (or pip install tavily-python) and re-run your program.
- Install crewai-tools with the full tool extra that includes tavily-python.
- Pin the dependency in pyproject.toml so environments are reproducible.
Example fix
# before TavilySearchTool() # prompt declined -> ImportError # after # shell: uv add tavily-python TavilySearchTool(api_key='tvly-...')
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec('tavily') is None:
raise SystemExit('Missing dependency: run uv add tavily-python') Try / catch
try:
from crewai_tools import TavilySearchTool
tool = TavilySearchTool(api_key=KEY)
except ImportError as e:
raise SystemExit(f'Setup required before running: {e}') Prevention
- Pin optional tool dependencies in requirements/pyproject so environments are complete.
- Run CI jobs with stdin closed and deps pre-installed to avoid interactive prompts.
- Add a startup dependency check for every tool your crew uses.
When it happens
Trigger: Instantiating TavilySearchTool without tavily-python installed and answering 'n' (or piping 'n'/EOF to stdin) to the 'Would you like to install it?' prompt.
Common situations: Non-interactive scripts where stdin is closed so click.confirm defaults to declining; minimal installs of crewai-tools without tool extras; CI pipelines that never answer prompts.
Related errors
- 'tavily-python' has been installed. Please restart your Pyth
- python-docx is required for DOCX loading. Install with: 'uv
- PDF support requires pymupdf. Install with: uv add pymupdf
- `minds_sdk` package not found, please run `pip install minds
- Could not import langchain_apify python package. Please inst
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/e809dcdc0691853b.
Report an issue: GitHub.