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 TavilyGetResearchTool.
What it means
TavilyGetResearchTool raises this ImportError on purpose after `subprocess.run(["uv", "add", "tavily-python"], check=True)` succeeds. The just-installed package cannot be imported into the already-running process reliably, so the exception instructs the user to restart. It signals success, not failure.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/tavily_get_research_tool/tavily_get_research_tool.py:81
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:
raise ImportError(
f"Attempted to install 'tavily-python' but failed: {e}. "
"Please install it manually to use the TavilyGetResearchTool."
) from e
else:
raise ImportError(
"The 'tavily-python' package is required to use the "
"TavilyGetResearchTool. Please install it with: uv add tavily-python"
)
@staticmethod
def _stringify_response(response: Any) -> str:
if isinstance(response, str):
return responseView on GitHub (pinned to 754d7323be)
Solutions
- Restart the Python process (or Jupyter kernel) and construct TavilyGetResearchTool again.
- Better: add tavily-python to project deps (uv add tavily-python / pip install) up front and skip the prompt entirely.
Defensive patterns
Strategy: try-catch
Validate before calling
import importlib.util
if importlib.util.find_spec("tavily") is None:
raise SystemExit("tavily-python not installed; install before starting the app") Try / catch
try:
tool = TavilyGetResearchTool()
except ImportError as e:
if "has been installed" in str(e):
os.execv(sys.executable, [sys.executable, *sys.argv]) # restart to load new package
raise Prevention
- Install tavily-python up front so the restart-required path never fires.
- In notebooks, plan a kernel restart after accepting any auto-install.
- Treat the 'restart' ImportError as a success code in orchestration wrappers.
When it happens
Trigger: Missing tavily-python, user answers 'y' to the click.confirm prompt, and `uv add tavily-python` exits 0. The ImportError is raised immediately after the successful install.
Common situations: Interactive first-run sessions where the developer accepts the auto-install; notebook users who must restart the kernel to pick up the new package.
Related errors
- 'tavily-python' has been installed. Please restart your Pyth
- 'tavily-python' has been installed. Please restart your Pyth
- The 'tavily-python' package is required. 'click' and 'subpro
- The 'tavily-python' package is required to use the TavilyExt
- The 'tavily-python' package is required. 'click' and 'subpro
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/cbd480d0aa485124.
Report an issue: GitHub.