crewAIInc/crewAI · error · ImportError

Failed to install oxylabs package

Error message

Failed to install oxylabs package

What it means

The universal scraper variant of the same flow: oxylabs not importable, user accepts the click.confirm install prompt, `subprocess.run(['uv','add','oxylabs'])` exits non-zero, and OxylabsUniversalScraperTool.__init__ raises ImportError('Failed to install oxylabs package') chained to the CalledProcessError.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/oxylabs_universal_scraper_tool/oxylabs_universal_scraper_tool.py:131

        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 = OxylabsUniversalScraperConfig()
        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 manually: pip install oxylabs (or uv add oxylabs from a uv project root).
  2. Read e.__cause__ / run `uv add oxylabs` yourself to see the true failure reason.
  3. Bake oxylabs into container images to avoid the interactive installer entirely.

Example fix

# before: auto uv add fails in pip project

# after
pip install oxylabs
Defensive patterns

Strategy: try-catch

Validate before calling

try:
    import oxylabs  # noqa: F401
except ImportError:
    raise SystemExit("pip install oxylabs before using OxylabsUniversalScraperTool")

Try / catch

try:
    tool = OxylabsUniversalScraperTool(username=u, password=p)
except ImportError as e:
    raise SystemExit(f"Install oxylabs manually (pip install oxylabs): underlying {e.__cause__}") from e

Prevention

When it happens

Trigger: Constructing OxylabsUniversalScraperTool without oxylabs, confirming the prompt, in a directory with no uv project (or with uv missing/offline) so `uv add oxylabs` fails.

Common situations: pip-based projects where `uv add` is invalid; CI images without uv; restricted networks blocking PyPI.

Related errors


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