pythonattributeerrorpyenchantword-listenchant

why i'm getting AttributeError when using 'enchant.DictWithPWL()' from 'enchant' module?


I'm using enchant module. It has an attribute DictWithPWL to add a personal word list to an existing dictionary that is pre-defined. But I'm getting the below error:

def dictionary_words_finder(word_lst):
    meaningful_word = []
    # creating a dictionary object for checking a word is in dictionary or not and also adding 
    # our personal word list from words.txt
    eng_dictionary = enchant.DictWithPWL("en_US", 'words.txt')
    for word in word_lst:
    
      if not eng_dictionary.check(word):
        continue
      else:
        meaningful_word.append(word)
    
    return meaningful_word`

But I'm getting the below error:

AttributeError: module 'enchant' has no attribute 'DictWithPWL'

Please let me know if there is any other way to do this task if you don't have a solution to the above problem.

I've installed the enchant module using !pip install enchant. Enchant module got installed successfully but the problem is not resolved. Also, I've searched for other methods for doing the same task but can't find any such modules or methods.

I expect that the above-written code should not throw AttributeError by making some changes to the above code.

I've also gone through documentation here --> https://pyenchant.github.io/pyenchant/tutorial.html enchant.DictWithPWL is still in their documentation but can't get where I'm doing it wrong. Please help.


Solution

  • You installed the wrong package. The package you're trying to use is named PyEnchant in PyPI. Try uninstalling enchant and installing PyEnchant.