Tag Archives: NLTK Error

NLTK Error: [Error:11004] getaddrinfo failed [How to Solve]

When I run nltk’s word segmentation:

from nltk.tokenize import word_tokenize
text = "God is Great! I won a lottery."
print(word_tokenize(text))

The Punkt package is missing, so the following code is used to download it:

import nltk
nltk.download()

report errors  [ Error:11004] getaddrinfo failed

resolvent:

1. Open the website to query the IP address: https://www.ipaddress.com/ , and enter raw.githubusercontent.com

2. Copy the following four websites

3. Open   C:\Windows\System32\drivers\etc\hosts   Paste the above URL to the back

NLTK Error [nltk_data] Error loading stopwords: hostname

Nltk error [nltk]_ Data] error loading stopwords: host name. Use the following code to download stopwords

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')
nltk.download('punkt')