Grzegorz Swirszcz
Grzegorz Swirszcz

Reputation: 101

pyenchant error "DictNotFoundError: Dictionary for language 'en_US' could not be found"

I am running Python 3.6 in Spyder/Anaconda, I am trying to use enchant. I installed pyenchant using

pip install pyenchant

I also installed aspell using

sudo apt-get install aspell-en

I am executing in Python:

import enchant

print("The dict is", enchant.list_languages())

slownik = enchant.Dict("en_US")

I keep getting an error:

File "/home/grzegorz/anaconda3/lib/python3.6/site-packages/enchant/init.py", line 562, in init _EnchantObject.init(self)

File "/home/grzegorz/anaconda3/lib/python3.6/site-packages/enchant/init.py", line 168, in init self._init_this()

File "/home/grzegorz/anaconda3/lib/python3.6/site-packages/enchant/init.py", line 569, in _init_this this = self._broker._request_dict_data(self.tag)

File "/home/grzegorz/anaconda3/lib/python3.6/site-packages/enchant/init.py", line 310, in _request_dict_data self._raise_error(eStr % (tag,),DictNotFoundError)

File "/home/grzegorz/anaconda3/lib/python3.6/site-packages/enchant/init.py", line 258, in _raise_error raise eclass(default)

DictNotFoundError: Dictionary for language 'en_US' could not be found

And the printout is:

The dict is []

so no dictionaries are being loaded. It seems that enchant does not know where the aspell dictionaries are located.

I tried numerous variations of

enchant.set_param("enchant.aspell.dictionary.path","/aspell") enchant.set_param("enchant.myspell.dictionary.path","/usr/bin/aspell")

What may be relevant: this simple code worked before I upgraded to Ubuntu 17.10 (from 17.4), so I somehow got enchant to work then, but it was long ago and I cannot recreate what I did differently when installing enchant back then. I have also updated Spyder to the latest version, one of those operations clearly caused the code to break. I was updating Spyder in the past and it did not cause any problems, so I am suspecting that during the system update something important got deleted/moved. I found answers for people with similar issues on MacOS, but the answers I found do not work on Ubuntu. Any help would be greatly appreciated.

Upvotes: 3

Views: 5704

Answers (1)

Grzegorz Swirszcz
Grzegorz Swirszcz

Reputation: 101

Temporary solution - downgrade to Python 3.5. It seems that pyenchant 1.6.11 is not Python 3.6 compatible and that it only tries to import Hspel (Hebrew) library when used with Python 3.6. I would love to be able to use the newest Python, so the issue is not resolved, but that is the best (and only) solution so far.

Upvotes: 2

Related Questions