crewAIInc/crewAI · error · ImportError

The 'tavily-python' package is required to use the TavilyRes

Error message

The 'tavily-python' package is required to use the TavilyResearchTool. Please install it with: uv add tavily-python

What it means

TavilyResearchTool raises this ImportError in the branch where the user declines the interactive install prompt. No install is attempted; the tool simply refuses to be usable without tavily-python and points to `uv add tavily-python`.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/tavily_research_tool/tavily_research_tool.py:127

                ) 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:
                    raise ImportError(
                        f"Attempted to install 'tavily-python' but failed: {e}. "
                        "Please install it manually to use the TavilyResearchTool."
                    ) from e
            else:
                raise ImportError(
                    "The 'tavily-python' package is required to use the "
                    "TavilyResearchTool. Please install it with: uv add tavily-python"
                )

    @staticmethod
    def _stringify_response(response: Any) -> str:
        if isinstance(response, str):
            return response
        return json.dumps(response, indent=2)

    def _run(
        self,
        input: str,
        model: Literal["mini", "pro", "auto"] | None = None,
        output_schema: dict[str, Any] | None = None,
        stream: bool | None = None,
        citation_format: Literal["numbered", "mla", "apa", "chicago"] | None = None,
    ) -> str | Generator[bytes, None, None]:

View on GitHub (pinned to 754d7323be)

Solutions

  1. Install tavily-python (uv add tavily-python or pip install tavily-python) and re-construct the tool.
  2. Bake the dependency into your environment/image to avoid prompts entirely.
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec("tavily") is None:
    raise SystemExit("tavily-python required for TavilyResearchTool. Install: uv add tavily-python")

Try / catch

try:
    tool = TavilyResearchTool()
except ImportError as e:
    if "required to use the" in str(e):
        log.warning("Tavily install declined at prompt; tool unavailable")
    raise

Prevention

When it happens

Trigger: TavilyResearchTool.__init__ with tavily-python missing and click.confirm answered 'n' (or declined implicitly in non-TTY contexts).

Common situations: Interactive terminals where the developer opts out; scripts whose stdin is not a TTY.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/d51369187626c1fa. Report an issue: GitHub.