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

When the oxylabs SDK is not importable and the user declines the interactive install prompt (click.confirm returns False), OxylabsAmazonProductScraperTool.__init__ raises ImportError instructing you to run `uv add oxylabs`. It is the explicit 'dependency missing, user said no' path.

Source

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

            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

    def _run(self, query: str) -> str:

View on GitHub (pinned to 754d7323be)

Solutions

  1. Install the dependency yourself: uv add oxylabs (uv projects) or pip install oxylabs.
  2. For non-interactive deployments, always pre-install oxylabs so this branch is never reached.
  3. Verify with python -c "import oxylabs" before constructing the tool.

Example fix

# before
tool = OxylabsAmazonProductScraperTool()  # prompt declined -> ImportError

# after
# pip install oxylabs
tool = OxylabsAmazonProductScraperTool()
Defensive patterns

Strategy: validation

Validate before calling

try:
    import oxylabs  # noqa: F401
    HAS_OXYLABS = True
except ImportError:
    HAS_OXYLABS = False

if not HAS_OXYLABS:
    raise SystemExit("Dependency missing: run `pip install oxylabs` (or `uv add oxylabs`) before building agents")

Try / catch

try:
    tool = OxylabsAmazonProductScraperTool(username=u, password=p)
except ImportError as e:
    if "oxylabs" in str(e):
        subprocess.run([sys.executable, "-m", "pip", "install", "oxylabs"], check=True)
        tool = OxylabsAmazonProductScraperTool(username=u, password=p)

Prevention

When it happens

Trigger: Instantiating OxylabsAmazonProductScraperTool without oxylabs installed and answering 'n' to 'Would you like to install it?', or running non-interactively where click.confirm reads EOF/defaults to no.

Common situations: CI pipelines and cron jobs with no TTY (the prompt cannot be answered, effectively declining); developers declining the prompt to control dependencies manually.

Related errors


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