crewAIInc/crewAI · error · ImportError

Failed to install oxylabs package

Error message

Failed to install oxylabs package

What it means

In OxylabsAmazonProductScraperTool.__init__, when the oxylabs SDK is absent the tool interactively asks (click.confirm) whether to install it, then runs `uv add oxylabs` via subprocess. If that subprocess exits non-zero (CalledProcessError), an ImportError 'Failed to install oxylabs package' is raised chained to the underlying error.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/oxylabs_amazon_product_scraper_tool/oxylabs_amazon_product_scraper_tool.py:135

        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 = OxylabsAmazonProductScraperConfig()
        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 the SDK manually in your environment: uv add oxylabs (inside a uv project) or pip install oxylabs.
  2. If not using uv, initialize a project (uv init) or switch the command to pip install oxylabs.
  3. Check network access and proxy settings for PyPI; re-run the install command directly to see the real error.
  4. Pre-install oxylabs in your Docker image so the interactive path is never hit.

Example fix

# before: prompt-driven install fails in CI
# (click.confirm -> uv add oxylabs -> CalledProcessError)

# after: pre-install in Dockerfile
RUN pip install oxylabs
Defensive patterns

Strategy: try-catch

Validate before calling

def oxylabs_available() -> bool:
    try:
        import oxylabs  # noqa: F401
        return True
    except ImportError:
        return False

if not oxylabs_available():
    raise SystemExit("Install first: pip install oxylabs")

Try / catch

try:
    tool = OxylabsAmazonProductScraperTool(username=u, password=p)
except ImportError as e:
    raise SystemExit(f"oxylabs unavailable: {e}. Install with: pip install oxylabs") from e

Prevention

When it happens

Trigger: oxylabs not installed + user answers 'yes' to the install prompt + `uv add oxylabs` fails: uv not on PATH (FileNotFoundError surfaces differently), no uv project/pyproject in cwd, network failure, or a resolver/permission error.

Common situations: Running inside a non-uv project (uv add requires a project context); CI/containers where the prompt gets EOF or uv is missing; offline environments; read-only file systems.

Related errors


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