NLTK error on deployment | Module cannot be found

So I’m trying to create a dictionary website using streamlit and wordnet from nltk inside an environment called “nlp” which already includes full nltk packages. Everything works properly except on deployment. I got a weird error message when I try to search a word on the deployed website, saying something like “this ‘wordnet’ package cannot be found” although I already added the nltk package inside the requirements.txt

Here’s the full error message
Resource e[93mwordnete[0m not found. Please use the NLTK Downloader to obtain the resource:

e[31m>>> import nltk

nltk.download(‘wordnet’) e[0m For more information see: NLTK :: Installing NLTK Data

Attempted to load e[93mcorpora/wordnete[0m

Searched in: - ‘/home/appuser/nltk_data’ - ‘/home/appuser/venv/nltk_data’ - ‘/home/appuser/venv/share/nltk_data’ - ‘/home/appuser/venv/lib/nltk_data’ - ‘/usr/share/nltk_data’ - ‘/usr/local/share/nltk_data’ - ‘/usr/lib/nltk_data’ - ‘/usr/local/lib/nltk_data’

Note: NLTK is installed inside the nlp conda environment

I’m completely stuck at this. Help me :')

Hi @Dylan_Mac,

The error message also states that in addition to installing NLTK in the nlp conda environment (as you have done), you need to additionally download the ‘wordnet’ package in your app.

Include the following in your app:

import nltk
nltk.download('wordnet')

Source: NLTK :: Installing NLTK Data

Best, :balloon:
Snehan

1 Like

I couldn’t believe it worked! Thank you very much!!!~

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.