{"record":{"id":"300287fb2db6afb7","repo":"crewAIInc/crewAI","slug":"scrapfly-sdk-package-not-found-please-run-uv-a","errorCode":null,"errorMessage":"`scrapfly-sdk` package not found, please run `uv add scrapfly-sdk`","messagePattern":"`scrapfly-sdk` package not found, please run `uv add scrapfly-sdk`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/scrapfly_scrape_website_tool/scrapfly_scrape_website_tool.py","lineNumber":63,"sourceCode":"\n    def __init__(self, api_key: str):\n        super().__init__(\n            name=\"Scrapfly web scraping API tool\",\n            description=\"Scrape a webpage url using Scrapfly and return its content as markdown or text\",\n        )\n        try:\n            from scrapfly import ScrapflyClient  # type: ignore[import-untyped]\n        except ImportError:\n            import click\n\n            if click.confirm(\n                \"You are missing the 'scrapfly-sdk' package. Would you like to install it?\"\n            ):\n                import subprocess\n\n                subprocess.run([\"uv\", \"add\", \"scrapfly-sdk\"], check=True)  # noqa: S607\n            else:\n                raise ImportError(\n                    \"`scrapfly-sdk` package not found, please run `uv add scrapfly-sdk`\"\n                ) from None\n        self.scrapfly = ScrapflyClient(key=api_key or os.getenv(\"SCRAPFLY_API_KEY\"))\n\n    def _run(\n        self,\n        url: str,\n        scrape_format: str = \"markdown\",\n        scrape_config: dict[str, Any] | None = None,\n        ignore_scrape_failures: bool | None = None,\n    ) -> str | None:\n        from scrapfly import ScrapeConfig\n\n        url = validate_url(url)\n        scrape_config = scrape_config if scrape_config is not None else {}\n        try:\n            response = self.scrapfly.scrape(  # type: ignore[union-attr]\n                ScrapeConfig(url, format=scrape_format, **scrape_config)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/scrapfly_scrape_website_tool/scrapfly_scrape_website_tool.py#L45-L81","documentation":"ImportError raised by ScrapflyScrapeWebsiteTool when the scrapfly-sdk package is not importable and the user declines the interactive install prompt (click.confirm). The tool asks 'Would you like to install it?' and runs `uv add scrapfly-sdk`; if you answer 'no' (or stdin is non-interactive so confirm fails/is declined), the ImportError is raised with the install command in the message. It fires during tool construction, before any scraping happens.","triggerScenarios":"Instantiating ScrapflyScrapeWebsiteTool without scrapfly-sdk installed: ImportError on 'from scrapfly import ScrapflyClient', the click.confirm prompt appears, and the user declines (or the environment auto-declines).","commonSituations":"Non-interactive environments (CI, Docker, agent runs) where click.confirm cannot prompt and defaults to no; forgetting to add the optional dependency after pulling in crewai-tools; deploying to a slim container that never had scrapfly-sdk.","solutions":["Install the dependency before constructing the tool: run `uv add scrapfly-sdk` (or `pip install scrapfly-sdk`).","For Docker/CI, add scrapfly-sdk to the image/requirements so the interactive prompt never triggers.","Pre-set SCRAPFLY_API_KEY as well, since the constructor reads it right after the import."],"exampleFix":"# before (CI, no TTY -> prompt auto-declined)\ntool = ScrapflyScrapeWebsiteTool()  # ImportError\n\n# after\n# Dockerfile / CI step:\n#   uv add scrapfly-sdk\ntool = ScrapflyScrapeWebsiteTool()","handlingStrategy":"validation","validationCode":"def scrapfly_available() -> bool:\n    try:\n        import scrapfly  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif not scrapfly_available():\n    subprocess.run([\"uv\", \"add\", \"scrapfly-sdk\"], check=True)","typeGuard":null,"tryCatchPattern":"try:\n    tool = ScrapflyScrapeWebsiteTool()\nexcept ImportError as e:\n    if \"scrapfly-sdk\" in str(e):\n        raise SystemExit(\"Run `uv add scrapfly-sdk` before using ScrapflyScrapeWebsiteTool\") from e\n    raise","preventionTips":["Add scrapfly-sdk to project dependencies up front; never rely on the runtime prompt in automation.","Pre-flight optional imports in CI to catch missing extras before deployment.","Set SCRAPFLY_API_KEY at the same time to avoid the next constructor failure."],"tags":["dependency","import-error","scrapfly","installation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}