{"record":{"id":"f7fa6486fe810d72","repo":"crewAIInc/crewAI","slug":"attempted-to-install-tavily-python-but-failed-f7fa64","errorCode":null,"errorMessage":"Attempted to install 'tavily-python' but failed: {e}. Please install it manually to use the TavilySearchTool.","messagePattern":"Attempted to install 'tavily-python' but failed: (.+?)\\. Please install it manually to use the TavilySearchTool\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py","lineNumber":144,"sourceCode":"                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:\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.","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/tavily_search_tool/tavily_search_tool.py#L126-L162","documentation":"TavilySearchTool tried to auto-install the missing 'tavily-python' package by shelling out to 'uv add tavily-python', but the subprocess exited non-zero (check=True raised CalledProcessError). The ImportError wraps the subprocess failure and asks you to install the package manually.","triggerScenarios":"Answering 'y' to the install prompt when 'tavily-python' is missing AND uv is absent from PATH, uv cannot resolve the package (offline, proxy blocked, lockfile conflict), or the project is not a uv workspace so 'uv add' fails.","commonSituations":"Restricted CI/network environments without PyPI access; using pip-managed venvs where 'uv add' has no project to modify; uv lock conflicts from an outdated uv.lock; running as a user without write access to the environment.","solutions":["Install manually with your actual package manager: pip install tavily-python (or uv add tavily-python after fixing the underlying uv error).","Check the wrapped CalledProcessError/stderr to see why uv failed (no network, lock conflict, no pyproject.toml).","If uv is missing, install uv (curl -LsSf https://astral.sh/uv/install.sh | sh) or skip uv and use pip.","Pre-install the dependency in your image/CI so the interactive path is never hit."],"exampleFix":"# before\nTavilySearchTool()  # prompts -> 'uv add tavily-python' fails -> ImportError\n\n# after\n# shell: pip install tavily-python  (or fix uv project: uv add tavily-python)\n# then restart the app\nTavilySearchTool(api_key='tvly-...')","handlingStrategy":"try-catch","validationCode":"import shutil\n\nif not shutil.which('uv'):\n    print('uv not on PATH - install deps with pip instead')","typeGuard":null,"tryCatchPattern":"try:\n    tool = TavilySearchTool(api_key=KEY)\nexcept ImportError as e:\n    if 'Attempted to install' in str(e):\n        subprocess.run([sys.executable, '-m', 'pip', 'install', 'tavily-python'], check=True)\n        sys.exit('Installed tavily-python - please restart the application')\n    raise","preventionTips":["Pre-install tavily-python in Docker/CI so 'uv add' never runs at runtime.","Ensure uv is installed and the project has a pyproject.toml if you expect 'uv add' to work.","Check network/proxy access for PyPI in the deployment environment."],"tags":["dependencies","installation","subprocess","uv","network"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}