crewAIInc/crewAI · error · ImportError
The 'tavily-python' package is required. 'click' and 'subpro
Error message
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.
What it means
TavilyResearchTool raises this ImportError during __init__ when tavily-python is absent and the installer helpers (click/subprocess) also fail to import. It is the same pattern as the other Tavily tools: the interactive install path is gated behind importing click and subprocess, and their failure aborts with pip-style guidance, chaining the original ImportError.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/tavily_research_tool/tavily_research_tool.py:103
),
]
)
def __init__(self, **kwargs: Any):
super().__init__(**kwargs)
if TAVILY_AVAILABLE:
api_key = os.getenv("TAVILY_API_KEY")
self._client = TavilyClient(api_key=api_key, client_name="crewai")
self._async_client = AsyncTavilyClient(
api_key=api_key, client_name="crewai"
)
else:
try:
import subprocess
import click
except ImportError as e:
raise ImportError(
"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 TavilyResearchTool. 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 TavilyResearchTool."
)
except subprocess.CalledProcessError as e:View on GitHub (pinned to 754d7323be)
Solutions
- pip install tavily-python click (or uv add tavily-python) before creating the tool.
- Add crewai-tools' tavily extra / tavily-python to your dependency lock so import never fails.
- In subprocess-hostile sandboxes, pre-install deps and avoid the fallback path.
Example fix
# before tool = TavilyResearchTool() # -> ImportError # after # shell: pip install tavily-python tool = TavilyResearchTool()
Defensive patterns
Strategy: try-catch
Validate before calling
import importlib.util
if importlib.util.find_spec("tavily") is None or importlib.util.find_spec("click") is None:
raise SystemExit("Install first: pip install tavily-python click") Try / catch
try:
tool = TavilyResearchTool()
except ImportError as e:
raise SystemExit(f"Missing dependency: {e}. Run: pip install tavily-python") from e Prevention
- Pin tavily-python in project dependencies; do not depend on runtime installs.
- Startup-check importability of optional tool deps before building crews.
- Keep click available in minimal images if you rely on interactive installs.
When it happens
Trigger: Constructing TavilyResearchTool with TAVILY_AVAILABLE False and click (or subprocess) unimportable in the runtime.
Common situations: Lean production images without click; restricted interpreters; environments where crewai-tools' optional tavily extra was never installed.
Related errors
- The 'tavily-python' package is required. 'click' and 'subpro
- The 'tavily-python' package is required. 'click' and 'subpro
- The 'tavily-python' package is required. 'click' and 'subpro
- 'tavily-python' has been installed. Please restart your Pyth
- The 'tavily-python' package is required to use the TavilyExt
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/c56da981eb256dea.
Report an issue: GitHub.