{"record":{"id":"c56da981eb256dea","repo":"crewAIInc/crewAI","slug":"the-tavily-python-package-is-required-click-a-c56da9","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_research_tool/tavily_research_tool.py","lineNumber":103,"sourceCode":"            ),\n        ]\n    )\n\n    def __init__(self, **kwargs: Any):\n        super().__init__(**kwargs)\n        if TAVILY_AVAILABLE:\n            api_key = os.getenv(\"TAVILY_API_KEY\")\n            self._client = TavilyClient(api_key=api_key, client_name=\"crewai\")\n            self._async_client = AsyncTavilyClient(\n                api_key=api_key, 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 \"\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:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/tavily_research_tool/tavily_research_tool.py#L85-L121","documentation":"TavilyResearchTool raises this ImportError during __init__ when tavily-python is absent and the installer helpers (click/subprocess) also fail to import. It is the same pattern as the other Tavily tools: the interactive install path is gated behind importing click and subprocess, and their failure aborts with pip-style guidance, chaining the original ImportError.","triggerScenarios":"Constructing TavilyResearchTool with TAVILY_AVAILABLE False and click (or subprocess) unimportable in the runtime.","commonSituations":"Lean production images without click; restricted interpreters; environments where crewai-tools' optional tavily extra was never installed.","solutions":["pip install tavily-python click (or uv add tavily-python) before creating the tool.","Add crewai-tools' tavily extra / tavily-python to your dependency lock so import never fails.","In subprocess-hostile sandboxes, pre-install deps and avoid the fallback path."],"exampleFix":"# before\ntool = TavilyResearchTool()  # -> ImportError\n\n# after\n# shell: pip install tavily-python\ntool = TavilyResearchTool()","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 = TavilyResearchTool()\nexcept ImportError as e:\n    raise SystemExit(f\"Missing dependency: {e}. Run: pip install tavily-python\") from e","preventionTips":["Pin tavily-python in project dependencies; do not depend on runtime installs.","Startup-check importability of optional tool deps before building crews.","Keep click available in minimal images if you rely on interactive installs."],"tags":["tavily","dependency","import-error","crewai-tools","installation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}