{"record":{"id":"b13005abef1db839","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"scrapegraph-py-is-not-installed-install-it-with","errorCode":null,"errorMessage":"scrapegraph_py is not installed. Install it with 'pip install scrapegraph-py'.","messagePattern":"scrapegraph_py is not installed\\. Install it with 'pip install scrapegraph-py'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/integrations/scrapegraph_py_compat.py","lineNumber":27,"sourceCode":"\nfrom typing import Any, Optional, Type\n\nfrom pydantic import BaseModel\n\n\ndef _detect_api() -> str:\n    try:\n        from scrapegraph_py import ScrapeGraphAI  # noqa: F401\n\n        return \"v3\"\n    except ImportError:\n        pass\n    try:\n        from scrapegraph_py import Client  # noqa: F401\n\n        return \"v2\"\n    except ImportError as e:\n        raise ImportError(\n            \"scrapegraph_py is not installed. Install it with 'pip install scrapegraph-py'.\"\n        ) from e\n\n\ndef _schema_to_dict(schema: Optional[Type[BaseModel]]) -> Optional[dict]:\n    if schema is None:\n        return None\n    if isinstance(schema, dict):\n        return schema\n    if isinstance(schema, type) and issubclass(schema, BaseModel):\n        return schema.model_json_schema()\n    return None\n\n\ndef _unwrap_result(result: Any) -> dict:\n    if hasattr(result, \"status\") and hasattr(result, \"data\"):\n        if result.status != \"success\":\n            raise RuntimeError(","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/integrations/scrapegraph_py_compat.py#L9-L45","documentation":"ImportError raised by _detect_api in the scrapegraph-py compatibility layer: it first tries the legacy SDK import (which passes silently), then tries 'from scrapegraph_py import Client'; if that also fails it raises with instructions to install scrapegraph-py. Any of the module's public helpers (extract, scrape, search) trigger the detection.","triggerScenarios":"Calling scrapegraphai.integrations.scrapegraph_py_compat.extract/scrape/search without the scrapegraph-py package installed; raised from the v2 detection branch via 'from e' chaining.","commonSituations":"Using the ScrapeGraph Cloud API compat shim with only the base scrapegraphai install; renamed/removed package in a newer SDK (v1 import passes but v2 is gone); broken virtualenv.","solutions":["pip install scrapegraph-py.","Verify with python -c 'from scrapegraph_py import Client'.","If it still fails after install, check for a dependency conflict (scrapegraph-py renamed or version-pinned elsewhere) and reinstall in the active environment."],"exampleFix":"# before\nfrom scrapegraphai.integrations.scrapegraph_py_compat import extract\nresult = extract(url, schema=Schema)  # ImportError\n\n# after\n# shell: pip install scrapegraph-py\nfrom scrapegraphai.integrations.scrapegraph_py_compat import extract\nresult = extract(url, schema=Schema)","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('scrapegraph_py') is None:\n    raise SystemExit('Install the SDK: pip install scrapegraph-py')","typeGuard":"def scrapegraph_py_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec('scrapegraph_py') is not None","tryCatchPattern":"try:\n    from scrapegraphai.integrations.scrapegraph_py_compat import extract\nexcept ImportError as e:\n    if 'scrapegraph_py' in str(e):\n        raise SystemExit('pip install scrapegraph-py') from e\n    raise","preventionTips":["Install scrapegraph-py when using the cloud-API compat layer.","Probe optional SDKs with find_spec before calling extract/scrape/search.","Pin a tested SDK version to survive upstream renames."],"tags":["missing-dependency","scrapegraph-py","import-error","integrations"],"backgroundTag":"optional-dependency-not-installed","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}