crewAIInc/crewAI · error · ImportError

`oxylabs` package not found, please run `uv add oxylabs`

Error message

`oxylabs` package not found, please run `uv add oxylabs`

What it means

Raised by OxylabsGoogleSearchScraperTool.__init__ when the oxylabs SDK is absent and the interactive install prompt is declined (or stdin is closed), so the tool refuses to construct and directs you to `uv add oxylabs`.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/oxylabs_google_search_scraper_tool/oxylabs_google_search_scraper_tool.py:142

            if click.confirm(
                "You are missing the 'oxylabs' package. Would you like to install it?"
            ):
                import subprocess

                try:
                    subprocess.run(["uv", "add", "oxylabs"], check=True)  # noqa: S607
                    from oxylabs import RealtimeClient

                    kwargs["oxylabs_api"] = RealtimeClient(
                        username=username,
                        password=password,
                        sdk_type=sdk_type,
                    )
                except subprocess.CalledProcessError as e:
                    raise ImportError("Failed to install oxylabs package") from e
            else:
                raise ImportError(
                    "`oxylabs` package not found, please run `uv add oxylabs`"
                )

        if config is None:
            config = OxylabsGoogleSearchScraperConfig()
        super().__init__(config=config, **kwargs)

    def _get_credentials_from_env(self) -> tuple[str, str]:
        username = os.environ.get("OXYLABS_USERNAME")
        password = os.environ.get("OXYLABS_PASSWORD")
        if not username or not password:
            raise ValueError(
                "You must pass oxylabs username and password when instantiating the tool "
                "or specify OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables"
            )
        return username, password

    def _run(self, query: str, **kwargs: Any) -> str:

View on GitHub (pinned to 754d7323be)

Solutions

  1. pip install oxylabs (or uv add oxylabs in a uv project) before instantiation.
  2. Add oxylabs to your requirements/pyproject so environments are built complete.
  3. Verify importability first: python -c "import oxylabs".

Example fix

# before
tool = OxylabsGoogleSearchScraperTool()  # ImportError

# after
# pip install oxylabs
tool = OxylabsGoogleSearchScraperTool(username=u, password=p)
Defensive patterns

Strategy: validation

Validate before calling

try:
    import oxylabs  # noqa: F401
except ImportError:
    raise SystemExit("Run `pip install oxylabs` (or `uv add oxylabs`) before constructing the tool")

Try / catch

try:
    tool = OxylabsGoogleSearchScraperTool(username=u, password=p)
except ImportError as e:
    raise SystemExit("Install oxylabs, then retry") from e

Prevention

When it happens

Trigger: OxylabsGoogleSearchScraperTool(...) with oxylabs not installed and click.confirm returning False — declined manually or because the process has no interactive stdin (CI, Docker, cron).

Common situations: Automated environments where the prompt is effectively declined; developers who do not want runtime dependency mutation.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/a1e46429333c6186. Report an issue: GitHub.