ScrapeGraphAI/Scrapegraph-ai · error · ImportError
Could not import the 'ddgs' package required for DuckDuckGo
Error message
Could not import the 'ddgs' package required for DuckDuckGo search. Please install it with `pip install -U ddgs`.
What it means
Raised by the DuckDuckGo backend when the optional 'ddgs' package is not installed. The error message tells the user to install it via pip. It is chained from the original ImportError.
Source
Thrown at scrapegraphai/utils/research_web.py:268
Helper function for DuckDuckGo search using the ``ddgs`` package.
The ``duckduckgo-search`` package was renamed to ``ddgs``; recent
``langchain-community`` releases import ``from ddgs import DDGS``, which
silently broke the previous langchain-based implementation. This calls
``ddgs`` directly so results no longer depend on parsing a formatted string.
Args:
query (str): Search query
max_results (int): Maximum number of results to return
proxy (str, optional): Proxy configuration
Returns:
List[str]: List of URLs from search results
"""
try:
from ddgs import DDGS
except ImportError as e:
raise ImportError(
"Could not import the 'ddgs' package required for DuckDuckGo "
"search. Please install it with `pip install -U ddgs`."
) from e
try:
with DDGS(proxy=proxy) as ddgs:
results = [
result["href"]
for result in ddgs.text(query, max_results=max_results)
if result.get("href")
]
return results
except Exception as e:
raise SearchRequestError(f"DuckDuckGo search failed: {str(e)}")
def _search_bing(
query: str, max_results: int, timeout: int, proxy: Optional[str] = NoneView on GitHub (pinned to 532dfffbf6)
Solutions
- pip install -U ddgs (or uv add ddgs)
- Or install scrapegraphai with the appropriate extras
- Or switch to an engine whose deps are already available (e.g. google scraping needs no extra package)
Example fix
// before # engine='duckduckgo' -> ImportError // after pip install -U ddgs
Defensive patterns
Strategy: validation
Validate before calling
try:
import ddgs # noqa
has_ddgs = True
except ImportError:
has_ddgs = False
if config.search_engine == "duckduckgo" and not has_ddgs:
config.search_engine = "google" Try / catch
try:
results = search_on_web(config)
except ImportError as e:
print(e); import subprocess; subprocess.run(["pip", "install", "-U", "ddgs"]) Prevention
- Install extras at environment setup time (pip install scrapegraphai[ocr]/search extras)
- Probe for optional packages before selecting that engine
When it happens
Trigger: Calling search_on_web with search_engine='duckduckgo' (or having it as default/fallback) without the ddgs package installed in the environment.
Common situations: Installing scrapegraphai without the [search] or duckduckgo extras; using a minimal Docker image; a fresh virtualenv where only core deps were installed.
Related errors
- module {__name__!r} has no attribute {name!r}
- DuckDuckGo search failed: {str(e)}
- The dependencies for screenshot scraping are not installed.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/20463dd63301e898.
Report an issue: GitHub.