crewAIInc/crewAI · warning · ImportError

'tavily-python' has been installed. Please restart your Pyth

Error message

'tavily-python' has been installed. Please restart your Python application to use the TavilyExtractorTool.

What it means

This ImportError is raised deliberately AFTER a successful interactive install of tavily-python (subprocess.run(..., check=True) returned 0). Because the package was installed into site-packages after the Python process started, the already-imported (failed) module state cannot be reused safely, so the tool tells you to restart. It is control flow via exception, not a real failure.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/tavily_extractor_tool/tavily_extractor_tool.py:112

                api_key=self.api_key, proxies=self.proxies, client_name="crewai"
            )
        else:
            try:
                import subprocess

                import click
            except ImportError:
                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., 'uv add tavily-python') and ensure 'click' and 'subprocess' are available."
                ) from None

            if click.confirm(
                "You are missing the 'tavily-python' package, which is required for TavilyExtractorTool. Would you like to install it?"
            ):
                try:
                    subprocess.run(["uv pip", "install", "tavily-python"], check=True)  # noqa: S607
                    raise ImportError(
                        "'tavily-python' has been installed. Please restart your Python application to use the TavilyExtractorTool."
                    )
                except subprocess.CalledProcessError as e:
                    raise ImportError(
                        f"Attempted to install 'tavily-python' but failed: {e}. "
                        f"Please install it manually to use the TavilyExtractorTool."
                    ) from e
            else:
                raise ImportError(
                    "The 'tavily-python' package is required to use the TavilyExtractorTool. "
                    "Please install it with: uv add tavily-python"
                )

    def _run(
        self,
        urls: list[str] | str,
    ) -> str:
        """Synchronously extracts content from the given URL(s).

View on GitHub (pinned to 754d7323be)

Solutions

  1. Restart the Python application/process so the freshly installed tavily-python is importable, then construct TavilyExtractorTool again.
  2. Prefer installing up front (uv add tavily-python) so no prompt/restart cycle is needed.
  3. If you hit FileNotFoundError instead, that is the broken ["uv pip", ...] argv in the extractor tool; install manually with pip/uv and report the bug upstream.
Defensive patterns

Strategy: try-catch

Validate before calling

import importlib.util
if importlib.util.find_spec("tavily") is None:
    raise SystemExit("tavily-python missing; install and start the app with it present")

Try / catch

try:
    tool = TavilyExtractorTool()
except ImportError as e:
    if "has been installed" in str(e):
        print("Dependency installed; restarting process...")
        os.execv(sys.executable, [sys.executable, *sys.argv])  # clean restart
    else:
        raise

Prevention

When it happens

Trigger: TavilyExtractorTool.__init__ with tavily-python missing, click.confirm(...) answered 'y', and subprocess.run(["uv pip", "install", "tavily-python"]) exiting 0. Note the argv is malformed ("uv pip" as a single token), so on most systems this branch is unreachable and you get FileNotFoundError instead.

Common situations: First-run onboarding flows where the user accepts the install prompt in an interactive session; CI jobs that accidentally answer prompts via piped stdin.

Related errors


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