python chatterbot [nltk_data] Error loading stopwords: <urlopen error [Errno 11004]

created at 06-21-2022 views: 12


Running the project gives the following error:

[nltk_data] Error loading stopwords: <urlopen error [Errno 11004]
[nltk_data]     getaddrinfo failed>
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [Errno 11004] getaddrinfo failed>

The workaround is as follows:

Go to the address:

Enter the directory /packages/corpora/ to find the corresponding file and put it under the corresponding file folder.

It is recommended to download the entire nltk_data project with a size of 695M, to avoid the situation that other problems cannot be downloaded!

Extract compressed file\nltk_data-gh-pages\packages

All files into the following directory


The directory installed by everyone here may be different. Here is the directory above.

Modify the corresponding file:

\venv\Lib\site-packages\chatterbot\ in the current project directory

(Some people's directories may not be under the current project, you can find the corresponding site-packages directory according to your own configuration and then find the corresponding files to modify)

The corresponding code nltk_download_corpus('xxx') needs to be modified as follows:

def download_nltk_stopwords():
    Download required NLTK stopwords corpus if it has not already been downloaded.

def download_nltk_wordnet():
    Download required NLTK corpora if they have not already been downloaded.

def download_nltk_averaged_perceptron_tagger():
    Download the NLTK averaged perceptron tagger that is required for this algorithm
    to run only if the corpora has not already been downloaded.

def download_nltk_vader_lexicon():
    Download the NLTK vader lexicon for sentiment analysis
    that is required for this algorithm to run.

I wish you a smooth solution to the problem

created at:06-21-2022
edited at: 06-25-2022: