Search code examples
pythonspacytextacy

Textacy has no module preprocess or normalize whitespace


Sudden problems with textacy

text3 = textacy.normalize_whitespace(text2) 

AttributeError: module 'textacy' has no attribute 'normalize_whitespace'

This happens in Python 3.7

The script worked perfectly for the past year. The other day this error started happening. I feel I've tried everything. The line is critical to the program.

I created a python 3.6 env and an earlier version of textacy. Can't import textacy there because it says I don't have cachetools - I do.

Is there an approach you can recommend?


Solution

  • This method is located at textacy.preprocessing, cf here and here, so you'll have to change the code to:

    from textacy import preprocessing
    text3 = preprocessing.normalize_whitespace(text2)