ScrapeGraphAI/Scrapegraph-ai · error · ImportError
The langchain_nvidia_ai_endpoints module is not installed.
Error message
The langchain_nvidia_ai_endpoints module is not installed.
Please install it using `pip install langchain-nvidia-ai-endpoints`. What it means
Nvidia.__new__ lazily imports ChatNVIDIA from langchain_nvidia_ai_endpoints and converts the ImportError into this instructive error. The Nvidia wrapper in scrapegraphai/models/nvidia.py is instantiated when model_provider is 'nvidia', so the failure happens during _create_llm.
Source
Thrown at scrapegraphai/models/nvidia.py:24
class Nvidia:
"""
A wrapper for the ChatNVIDIA class that provides default configuration
and could be extended with additional methods if needed.
Note: This class uses __new__ instead of __init__ because langchain_nvidia_ai_endpoints
is an optional dependency. We cannot inherit from ChatNVIDIA at class definition time
since the module may not be installed. The __new__ method allows us to lazily import
and return a ChatNVIDIA instance only when Nvidia() is instantiated.
Args:
llm_config (dict): Configuration parameters for the language model.
"""
def __new__(cls, **llm_config):
try:
from langchain_nvidia_ai_endpoints import ChatNVIDIA
except ImportError:
raise ImportError(
"""The langchain_nvidia_ai_endpoints module is not installed.
Please install it using `pip install langchain-nvidia-ai-endpoints`."""
)
if "api_key" in llm_config:
llm_config["nvidia_api_key"] = llm_config.pop("api_key")
return ChatNVIDIA(**llm_config)
View on GitHub (pinned to 532dfffbf6)
Solutions
- pip install langchain-nvidia-ai-endpoints.
- Ensure the installed version matches your langchain-core version (upgrade both together if needed).
- Confirm with python -c 'from langchain_nvidia_ai_endpoints import ChatNVIDIA'.
Example fix
# before
config = {'llm': {'model_provider': 'nvidia', 'api_key': key}}
SmartScraperGraph(prompt=..., config=config) # ImportError
# after
# shell: pip install langchain-nvidia-ai-endpoints
config = {'llm': {'model_provider': 'nvidia', 'api_key': key}}
SmartScraperGraph(prompt=..., config=config) Defensive patterns
Strategy: validation
Validate before calling
if config['llm'].get('model_provider') == 'nvidia':
import importlib.util
if importlib.util.find_spec('langchain_nvidia_ai_endpoints') is None:
raise SystemExit('Run: pip install langchain-nvidia-ai-endpoints') Type guard
def nvidia_available() -> bool:
import importlib.util
return importlib.util.find_spec('langchain_nvidia_ai_endpoints') is not None Try / catch
try:
graph = SmartScraperGraph(prompt=p, config=config)
except ImportError as e:
if 'langchain_nvidia_ai_endpoints' in str(e):
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'langchain-nvidia-ai-endpoints'])
graph = SmartScraperGraph(prompt=p, config=config)
else:
raise Prevention
- Add langchain-nvidia-ai-endpoints to requirements when using the nvidia provider.
- Probe optional integrations with find_spec before graph construction.
- Keep langchain / endpoint-package versions in sync.
When it happens
Trigger: config = {'llm': {'model_provider': 'nvidia', 'model': 'meta/llama-3.1-70b-instruct', 'api_key': ...}} without langchain-nvidia-ai-endpoints installed.
Common situations: Base install lacking the optional NVIDIA integration; new CI/container images; environments where the package was pruned or the langchain version makes the endpoint package uninstallable.
Related errors
- The langchain_together module is not installed.
- burr package is not installed. Please install
- scrapegraph_py is not installed. Install it with 'pip instal
- Model not supported
- module {__name__!r} has no attribute {name!r}
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/dab243d026630963.
Report an issue: GitHub.