{"record":{"id":"2c2f8de42539020e","repo":"crewAIInc/crewAI","slug":"tavily-python-has-been-installed-please-restart-2c2f8d","errorCode":null,"errorMessage":"'tavily-python' has been installed. Please restart your Python application to use the TavilyResearchTool.","messagePattern":"'tavily-python' has been installed\\. Please restart your Python application to use the TavilyResearchTool\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"warning","filePath":"lib/crewai-tools/src/crewai_tools/tools/tavily_research_tool/tavily_research_tool.py","lineNumber":117,"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 TavilyResearchTool. 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 TavilyResearchTool.\"\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 TavilyResearchTool.\"\n                    ) from e\n            else:\n                raise ImportError(\n                    \"The 'tavily-python' package is required to use the \"\n                    \"TavilyResearchTool. 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":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/tavily_research_tool/tavily_research_tool.py#L99-L135","documentation":"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.","triggerScenarios":"tavily-python missing, click.confirm answered 'y', and `uv add tavily-python` returning exit code 0.","commonSituations":"Interactive onboarding in a fresh clone; notebooks (kernel restart required); long-lived processes that then need re-invocation.","solutions":["Restart the Python process/kernel and construct TavilyResearchTool again.","Prefer declarative dependency management: add tavily-python to pyproject.toml before running."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec(\"tavily\") is None:\n    raise SystemExit(\"tavily-python missing; install before starting\")","typeGuard":null,"tryCatchPattern":"try:\n    tool = TavilyResearchTool()\nexcept ImportError as e:\n    if \"has been installed\" in str(e):\n        os.execv(sys.executable, [sys.executable, *sys.argv])\n    raise","preventionTips":["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."],"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-15T17:31:12.345Z"}