{"record":{"id":"554ec64af72894b2","repo":"mem0ai/mem0","slug":"failed-to-download-spacy-model-en-core-web-sm-e","errorCode":null,"errorMessage":"Failed to download spaCy model en_core_web_sm: {e}. Please install manually: python -m spacy download en_core_web_sm","messagePattern":"Failed to download spaCy model en_core_web_sm: (.+?)\\. Please install manually: python -m spacy download en_core_web_sm","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mem0/utils/spacy_models.py","lineNumber":38,"sourceCode":"\ndef _ensure_model_available():\n    \"\"\"Download en_core_web_sm if spaCy is installed but model is missing.\"\"\"\n    try:\n        import spacy\n    except ImportError:\n        raise ImportError(\n            \"spaCy is not installed. Install it with: pip install mem0ai[nlp]\"\n        )\n\n    if not spacy.util.is_package(\"en_core_web_sm\"):\n        logger.info(\"Downloading spaCy model en_core_web_sm...\")\n        try:\n            from spacy.cli import download\n\n            download(\"en_core_web_sm\")\n            logger.info(\"spaCy model en_core_web_sm downloaded successfully\")\n        except Exception as e:\n            raise RuntimeError(\n                f\"Failed to download spaCy model en_core_web_sm: {e}. \"\n                \"Please install manually: python -m spacy download en_core_web_sm\"\n            ) from e\n\n\ndef get_nlp_full():\n    \"\"\"Return spaCy model with all pipelines (NER, tagger, etc.) for entity extraction.\"\"\"\n    global _nlp_full, _load_failed_full\n    if _load_failed_full:\n        return None\n    if _nlp_full is not None:\n        return _nlp_full\n    with _lock:\n        if _nlp_full is not None:\n            return _nlp_full\n        if _load_failed_full:\n            return None\n        try:","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/utils/spacy_models.py#L20-L56","documentation":"Raised by _ensure_model_available in mem0.utils.spacy_models when spaCy is installed but the en_core_web_sm model is missing and the automatic spacy.cli.download('en_core_web_sm') attempt raised (network error, no wheel for your Python version, no write access to the model directory). The original exception is chained via 'from e', so the cause is preserved.","triggerScenarios":"Air-gapped or proxied environments where the model download from GitHub releases is blocked; a Python version (e.g. 3.13 pre-release) with no published en_core_web_sm wheel; read-only site-packages; corporate TLS interception breaking the download.","commonSituations":"Docker builds with restricted egress; CI sandboxes; offline deployments where the model was never baked into the image; pip install --user environments without write permissions.","solutions":["Pre-install the model manually in the image/venv: python -m spacy download en_core_web_sm","If offline: pip install the model wheel directly from https://github.com/explosion/spacy-models/releases (e.g. en_core_web_sm-3.x.x-py3-none-any.whl)","Check the chained exception for the real cause (DNS/TLS/404) and fix network/proxy accordingly","Bake the model into the Docker layer during build, not at runtime"],"exampleFix":"# before: RuntimeError: Failed to download spaCy model en_core_web_sm ...\nfrom mem0 import Memory\n\n# after (in Dockerfile)\n# RUN pip install spacy && python -m spacy download en_core_web_sm\nfrom mem0 import Memory","handlingStrategy":"try-catch","validationCode":"import spacy\nif not spacy.util.is_package('en_core_web_sm'):\n    offline = not network_available()  # your check\n    if offline:\n        raise ConfigError('pre-install en_core_web_sm: python -m spacy download en_core_web_sm')","typeGuard":null,"tryCatchPattern":"try:\n    from mem0.utils.spacy_models import get_nlp_full\n    nlp = get_nlp_full()\nexcept RuntimeError as e:\n    if 'Failed to download spaCy model' in str(e):\n        log.error('bake en_core_web_sm into the image; see chained cause')\n        raise\n    raise","preventionTips":["Bake python -m spacy download en_core_web_sm into the Docker build","Check chained exception for the network root cause","For offline hosts, install the model wheel from a local mirror","Match the spaCy major version to a published en_core_web_sm wheel"],"tags":["spacy","nlp","network","model-download","offline"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}