{"record":{"id":"cbd480d0aa485124","repo":"crewAIInc/crewAI","slug":"tavily-python-has-been-installed-please-restart-cbd480","errorCode":null,"errorMessage":"'tavily-python' has been installed. Please restart your Python application to use the TavilyGetResearchTool.","messagePattern":"'tavily-python' has been installed\\. Please restart your Python application to use the TavilyGetResearchTool\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"warning","filePath":"lib/crewai-tools/src/crewai_tools/tools/tavily_get_research_tool/tavily_get_research_tool.py","lineNumber":81,"sourceCode":"                import subprocess\n\n                import click\n            except ImportError as e:\n                raise ImportError(\n                    \"The 'tavily-python' package is required. 'click' and \"\n                    \"'subprocess' are also needed to assist with installation \"\n                    \"if the package is missing. Please install 'tavily-python' \"\n                    \"manually (e.g., 'pip install tavily-python') and ensure \"\n                    \"'click' and 'subprocess' are available.\"\n                ) from e\n\n            if click.confirm(\n                \"You are missing the 'tavily-python' package, which is required \"\n                \"for TavilyGetResearchTool. Would you like to install it?\"\n            ):\n                try:\n                    subprocess.run([\"uv\", \"add\", \"tavily-python\"], check=True)  # noqa: S607\n                    raise ImportError(\n                        \"'tavily-python' has been installed. Please restart your \"\n                        \"Python application to use the TavilyGetResearchTool.\"\n                    )\n                except subprocess.CalledProcessError as e:\n                    raise ImportError(\n                        f\"Attempted to install 'tavily-python' but failed: {e}. \"\n                        \"Please install it manually to use the TavilyGetResearchTool.\"\n                    ) from e\n            else:\n                raise ImportError(\n                    \"The 'tavily-python' package is required to use the \"\n                    \"TavilyGetResearchTool. Please install it with: uv add tavily-python\"\n                )\n\n    @staticmethod\n    def _stringify_response(response: Any) -> str:\n        if isinstance(response, str):\n            return response","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/tavily_get_research_tool/tavily_get_research_tool.py#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"Interactive first-run sessions where the developer accepts the auto-install; notebook users who must restart the kernel to pick up the new package.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec(\"tavily\") is None:\n    raise SystemExit(\"tavily-python not installed; install before starting the app\")","typeGuard":null,"tryCatchPattern":"try:\n    tool = TavilyGetResearchTool()\nexcept ImportError as e:\n    if \"has been installed\" in str(e):\n        os.execv(sys.executable, [sys.executable, *sys.argv])  # restart to load new package\n    raise","preventionTips":["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."],"tags":["tavily","installation","restart-required","import-error","crewai-tools"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}