crewAIInc/crewAI · error · ImportError

Failed to install oxylabs package

Error message

Failed to install oxylabs package

What it means

The Google search scraper variant of the auto-install flow: oxylabs missing, user accepts the click.confirm prompt, `uv add oxylabs` raises CalledProcessError, and ImportError('Failed to install oxylabs package') propagates from OxylabsGoogleSearchScraperTool.__init__.

Source

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

        else:
            import click

            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

View on GitHub (pinned to 754d7323be)

Solutions

  1. Install oxylabs with your actual package manager: pip install oxylabs.
  2. If using uv, run from the uv project root so `uv add oxylabs` succeeds.
  3. Check the __cause__ output for uv's specific error and fix network/proxy issues.

Example fix

# before: auto-install path fails
# (click.confirm yes -> uv add oxylabs fails)

# after: explicit install
pip install oxylabs
Defensive patterns

Strategy: try-catch

Validate before calling

try:
    import oxylabs  # noqa: F401
except ImportError:
    raise SystemExit("Install oxylabs first: pip install oxylabs")

Try / catch

try:
    tool = OxylabsGoogleSearchScraperTool(username=u, password=p)
except ImportError as e:
    raise SystemExit(f"oxylabs install failed: {e.__cause__}") from e

Prevention

When it happens

Trigger: Constructing OxylabsGoogleSearchScraperTool without oxylabs, answering yes, while uv fails — typically because there is no uv-managed project (pyproject.toml/lock) in the current directory, uv is not installed, or PyPI is unreachable.

Common situations: Using pip/poetry/pdm-managed projects where `uv add` is the wrong command; offline or proxied CI environments.

Related errors


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