'I tried to import the nltk package once i installed it, but i got an error. does anyone have any idea how to fix it please

I installed nltk:

!pip install nltk

then imported it with some related functions:

import nltk

nltk.download('punkt')

nltk.download('stopwords')

nltk.download('averaged_perceptron_tagger')

nltk.download('wordnet')

from nltk.tokenize import sent_tokenize, word_tokenize 

from nltk.corpus import stopwords

from nltk.stem import PorterStemmer

from nltk.stem import WordNetLemmatizer 

from nltk.corpus import wordnet

but I got this error message:

module 'regex.regex' has no attribute 'RegexFlag'.


Solution 1:[1]

According to this github comment, the issue seems to come from an outdated version of regex.

Upating the regex library to its newest version should solve the problem:

pip install regex --upgrade

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 robinood