Skip to content

nltk stopwords silent download error #273

Description

@nsmarks

In https://github.com/stanford-oval/genienlp/blob/master/genienlp/ned/ned_utils.py#L38, if the download of nltk stopwords fails, it does so silently. The quiet flag suppresses errors.

Error seen:

>>> nltk.download('stopwords')
[nltk_data] Error loading stopwords: <urlopen error [SSL:
[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data]     unable to get local issuer certificate (_ssl.c:1131)>
False

Solution from https://stackoverflow.com/questions/38916452/nltk-download-ssl-certificate-verify-failed:

import nltk
import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    pass
else:
    ssl._create_default_https_context = _create_unverified_https_context

nltk.download('stopwords')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions