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 TavilyResearchTool.

What it means

TavilyResearchTool raises this ImportError intentionally after `subprocess.run(["uv", "add", "tavily-python"], check=True)` exits successfully. Because the module was installed into the environment mid-process, the tool cannot import it cleanly in the same run and asks for a restart. Success message delivered via exception.

Source

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

                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:
                    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

View on GitHub (pinned to 754d7323be)

Solutions

  1. Restart the Python process/kernel and construct TavilyResearchTool again.
  2. Prefer declarative dependency management: add tavily-python to pyproject.toml before running.
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 before starting")

Try / catch

try:
    tool = TavilyResearchTool()
except ImportError as e:
    if "has been installed" in str(e):
        os.execv(sys.executable, [sys.executable, *sys.argv])
    raise

Prevention

When it happens

Trigger: tavily-python missing, click.confirm answered 'y', and `uv add tavily-python` returning exit code 0.

Common situations: Interactive onboarding in a fresh clone; notebooks (kernel restart required); long-lived processes that then need re-invocation.

Related errors


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