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

TavilyGetResearchTool raises this ImportError in __init__ when tavily-python is missing and the installer helpers (click, subprocess) cannot be imported either. Unlike the extractor tool, this variant uses pip-style guidance and chains the original ImportError via `from e`. The prompt path is never reached because the helper imports fail first.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/tavily_get_research_tool/tavily_get_research_tool.py:67

            ),
        ]
    )

    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 TavilyGetResearchTool. 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 TavilyGetResearchTool."
                    )
                except subprocess.CalledProcessError as e:

View on GitHub (pinned to 754d7323be)

Solutions

  1. pip install tavily-python (or uv add tavily-python) before constructing the tool.
  2. Ensure click is installed: pip install click.
  3. In subprocess-restricted runtimes, pre-install dependencies so the fallback is never exercised.

Example fix

# before
tool = TavilyGetResearchTool()  # -> ImportError

# after
# shell: pip install tavily-python click
tool = TavilyGetResearchTool()
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 = TavilyGetResearchTool()
except ImportError as e:
    raise SystemExit(f"Dependency missing: {e}. Run: pip install tavily-python") from e

Prevention

When it happens

Trigger: Constructing TavilyGetResearchTool where TAVILY_AVAILABLE is False and click (or subprocess) is unimportable — missing click install, restricted interpreter, or broken sys.path.

Common situations: Minimal containers without click; sandboxes that forbid subprocess; environments where crewai-tools was installed without its tavily extra and click is not otherwise pulled in.

Related errors


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