D4Vinci/Scrapling · critical · ModuleNotFoundError

This integration requires Scrapy installed, please install i

Error message

This integration requires Scrapy installed, please install it first with `pip install scrapy`

What it means

ModuleNotFoundError raised at import time of scrapling.integrations.scrapy when the `scrapy` package is not installed. The integration imports scrapy.http.Response to convert Scrapy responses; without Scrapy present it fails fast with an install hint, chained from the original ImportError.

Source

Thrown at scrapling/integrations/scrapy.py:17

"""Scrapy integration.

Decorate Scrapy spider callbacks with `scrapling_response` to receive a Scrapling `Response`
object instead of the Scrapy response, so you get Scrapling's full parsing API inside existing
Scrapy projects without changing how the spider crawls.
"""

from functools import partial, wraps
from inspect import isasyncgenfunction, iscoroutinefunction, isgeneratorfunction

from scrapling.core._types import Any, Callable, Dict, Optional, Tuple
from scrapling.engines.toolbelt.custom import Response, StatusText

try:
    from scrapy.http import Response as ScrapyResponse
except (ImportError, ModuleNotFoundError) as e:
    raise ModuleNotFoundError(
        "This integration requires Scrapy installed, please install it first with `pip install scrapy`"
    ) from e

__all__ = ["scrapling_response", "convert_response"]


def convert_response(response: ScrapyResponse, **selector_config: Any) -> Response:
    """Convert a Scrapy response to a Scrapling `Response` object.

    Can be used directly anywhere you have a Scrapy response at hand (middlewares, pipelines, ...).

    :param response: The Scrapy response to convert.
    :param selector_config: Configuration options passed to the `Response` constructor, like
        `huge_tree`, `keep_comments`, `keep_cdata`, `adaptive`, `storage`, `storage_args`, and `adaptive_domain`.
    :return: A Scrapling `Response` object ready for parsing.
    """
    request = response.request
    cookies: Dict[str, str] = {}

View on GitHub (pinned to 5d213a2d47)

Solutions

  1. Install scrapy in the active environment: pip install scrapy.
  2. Add scrapy (and scrapling) explicitly to requirements.txt/pyproject so deployments include it.
  3. Verify the right interpreter: `pip show scrapy` or `python -c 'import scrapy'` with the same python you run.
  4. If scrapy is genuinely optional in your tool, guard the import with try/except ImportError and degrade gracefully.

Example fix

# before
from scrapling.integrations.scrapy import scrapling_response  # ModuleNotFoundError

# after
# shell: pip install scrapy
from scrapling.integrations.scrapy import scrapling_response
Defensive patterns

Strategy: fallback

Validate before calling

import importlib.util

if importlib.util.find_spec("scrapy") is None:
    raise SystemExit("scrapy is required for the scrapling integration: pip install scrapy")

from scrapling.integrations.scrapy import scrapling_response

Type guard

def scrapy_available() -> bool:
    import importlib.util
    return importlib.util.find_spec("scrapy") is not None

Try / catch

try:
    from scrapling.integrations.scrapy import scrapling_response
except ModuleNotFoundError as e:
    if "Scrapy" in str(e):
        scrapling_response = None  # disable integration path
    else:
        raise

Prevention

When it happens

Trigger: `from scrapling.integrations.scrapy import scrapling_response` in an environment where `pip install scrapy` was never run, or where scrapy sits in a different virtualenv than the one running the code.

Common situations: Deploying spiders to a fresh venv/container built from an incomplete requirements file; having scrapy as an optional extra that was not included; IDE running tests with a different interpreter than the project env.

Related errors


AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14). Data as JSON: /api/errors/0e6c8992a70a6b8f. Report an issue: GitHub.