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 responseView on GitHub (pinned to 754d7323be)
Solutions
- Restart the Python process/kernel and construct TavilyResearchTool again.
- 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
- Pre-install tavily-python to skip the restart dance entirely.
- In orchestrators, catch the 'restart' ImportError and re-exec cleanly.
- Use declarative dependency management (pyproject/lock) over interactive installs.
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
- '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/2c2f8de42539020e.
Report an issue: GitHub.