{"record":{"id":"e809dcdc0691853b","repo":"crewAIInc/crewAI","slug":"the-tavily-python-package-is-required-to-use-the-e809dc","errorCode":null,"errorMessage":"The 'tavily-python' package is required to use the TavilySearchTool. Please install it with: uv add tavily-python","messagePattern":"The 'tavily-python' package is required to use the TavilySearchTool\\. Please install it with: uv add tavily-python","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py","lineNumber":149,"sourceCode":"                    \"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:\n                raise ImportError(\n                    \"The 'tavily-python' package is required to use the TavilySearchTool. \"\n                    \"Please install it with: uv add tavily-python\"\n                )\n\n    def _run(\n        self,\n        query: str,\n    ) -> str:\n        \"\"\"Synchronously performs a search using the Tavily API.\n        Content of each result is truncated to `max_content_length_per_result`.\n\n        Args:\n            query: The search query string.\n\n        Returns:\n            A JSON string containing the search results with truncated content.\n        \"\"\"\n        if not self.client:","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py#L131-L167","documentation":"TavilySearchTool requires the optional 'tavily-python' package. When it is missing and you decline the interactive offer to auto-install it (click.confirm returns False), the constructor raises ImportError with the uv add command to run.","triggerScenarios":"Instantiating TavilySearchTool without tavily-python installed and answering 'n' (or piping 'n'/EOF to stdin) to the 'Would you like to install it?' prompt.","commonSituations":"Non-interactive scripts where stdin is closed so click.confirm defaults to declining; minimal installs of crewai-tools without tool extras; CI pipelines that never answer prompts.","solutions":["Run: uv add tavily-python (or pip install tavily-python) and re-run your program.","Install crewai-tools with the full tool extra that includes tavily-python.","Pin the dependency in pyproject.toml so environments are reproducible."],"exampleFix":"# before\nTavilySearchTool()  # prompt declined -> ImportError\n\n# after\n# shell: uv add tavily-python\nTavilySearchTool(api_key='tvly-...')","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec('tavily') is None:\n    raise SystemExit('Missing dependency: run uv add tavily-python')","typeGuard":null,"tryCatchPattern":"try:\n    from crewai_tools import TavilySearchTool\n    tool = TavilySearchTool(api_key=KEY)\nexcept ImportError as e:\n    raise SystemExit(f'Setup required before running: {e}')","preventionTips":["Pin optional tool dependencies in requirements/pyproject so environments are complete.","Run CI jobs with stdin closed and deps pre-installed to avoid interactive prompts.","Add a startup dependency check for every tool your crew uses."],"tags":["dependencies","import","installation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}