{"record":{"id":"9f4cbbf3ece8ccd4","repo":"crewAIInc/crewAI","slug":"the-tavily-python-package-is-required-click-a-9f4cbb","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py","lineNumber":130,"sourceCode":"        ]\n    )\n\n    def __init__(self, **kwargs: Any):\n        super().__init__(**kwargs)\n        if TAVILY_AVAILABLE:\n            self.client = TavilyClient(\n                api_key=self.api_key, proxies=self.proxies, client_name=\"crewai\"\n            )\n            self.async_client = AsyncTavilyClient(\n                api_key=self.api_key, proxies=self.proxies, client_name=\"crewai\"\n            )\n        else:\n            try:\n                import subprocess\n\n                import click\n            except ImportError as e:\n                raise ImportError(\n                    \"The 'tavily-python' package is required. 'click' and 'subprocess' are also needed to assist with installation if the package is missing. \"\n                    \"Please install 'tavily-python' manually (e.g., 'pip install tavily-python') and ensure 'click' and 'subprocess' are available.\"\n                ) from e\n\n            if click.confirm(\n                \"You are missing the 'tavily-python' package, which is required for TavilySearchTool. 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 Python application to use the TavilySearchTool.\"\n                    )\n                except subprocess.CalledProcessError as e:\n                    raise ImportError(\n                        f\"Attempted to install 'tavily-python' but failed: {e}. \"\n                        f\"Please install it manually to use the TavilySearchTool.\"\n                    ) from e\n            else:","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py#L112-L148","documentation":"TavilySearchTool raises this ImportError in __init__ when tavily-python is missing and the installer helper modules (click, subprocess) also fail to import. The interactive install prompt never runs because the helper imports abort first; the message suggests pip install tavily-python.","triggerScenarios":"Constructing TavilySearchTool in an environment where TAVILY_AVAILABLE is False and click (or subprocess) cannot be imported.","commonSituations":"Slim Docker images lacking click; locked-down runners; crewai-tools installed without optional extras.","solutions":["pip install tavily-python click (or uv add tavily-python) before creating the tool.","Pin tavily-python in project dependencies so the import always succeeds.","Avoid the fallback path in sandboxes by pre-installing everything."],"exampleFix":"# before\ntool = TavilySearchTool()  # -> ImportError\n\n# after\n# shell: pip install tavily-python\ntool = TavilySearchTool()","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec(\"tavily\") is None or importlib.util.find_spec(\"click\") is None:\n    raise SystemExit(\"Install first: pip install tavily-python click\")","typeGuard":null,"tryCatchPattern":"try:\n    tool = TavilySearchTool(api_key=os.environ[\"TAVILY_API_KEY\"])\nexcept ImportError as e:\n    raise SystemExit(f\"Missing dependency: {e}. Run: pip install tavily-python\") from e","preventionTips":["Declare tavily-python in project dependencies (with click) rather than triggering runtime installs.","Startup-validate optional deps for every tool you wire into a crew.","Pre-install in Docker/CI images to keep tool construction deterministic."],"tags":["tavily","dependency","import-error","crewai-tools","installation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}