AttributeError: module 'regex' has no attribute 'Pattern'

Question:

I’m getting this error while trying to run this code in google colab:

!pip install dataprep
from dataprep.eda import create_report

Error:

NumExpr defaulting to 2 threads.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-db62224f8a79> in <module>()
----> 1 from dataprep.eda import create_report

10 frames
/usr/local/lib/python3.7/dist-packages/nltk/tokenize/casual.py in TweetTokenizer()
    355 
    356     @property
--> 357     def WORD_RE(self) -> regex.Pattern:
    358         """Core TweetTokenizer regex"""
    359         # Compiles the regex for this and all future instantiations of TweetTokenizer.

AttributeError: module 'regex' has no attribute 'Pattern'

Thing is pretty strange, as this code worked fine yesterday.
Any ideas?

Error

Asked By: misterbobot

||

Answers:

This looks like a known issue in NLTK. Perhaps update the NLTK version.

Answered By: ogdenkev

I was able to resolve this by upgrading to the latest versio to nltk 3.7, by using below command.

pip install nltk -U
Answered By: user19592122