Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyenchant can't find dictionary file on Mac OS X

I'm having trouble installing pyenchant on a MacbookPro running Lion. I've used homebrew and pip to install enchant and pyenchant

homebrew install enchant

pip install pyenchant

I've also downloaded an English dictionary to the following folder:

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/enchant/share/enchant/myspell

-rw-r--r--  1 mycomputer  admin      75 Jun  6 13:34 README.txt
-rw-rw-rw-@ 1 mycomputer  staff    1017 May  4  2007 README_en_US.txt
drwx------@ 2 mycomputer  staff      68 Jun  6 13:38 en_US
-rw-rw-rw-@ 1 mycomputer  staff    3045 May  4  2007 en_US.aff
-rw-rw-rw-@ 1 mycomputer  staff  696131 May  4  2007 en_US.dic

However, when I try to use enchant, I get the following error.

>>> import enchant
>>> d = enchant.Dict('en_US')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/enchant/__init__.py", line 502, in __init__
    self._switch_this(broker._request_dict_data(tag),broker)
  File "/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/enchant/__init__.py", line 264, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/enchant/__init__.py", line 218, in _raise_error
    raise eclass(default)
enchant.errors.DictNotFoundError: Dictionary for language 'en_US' could not be found

I'm guessing I don't have the dictionary files installed in the correct folder, but I don't know where else to install them.

Thanks.

like image 713
drbv Avatar asked Jun 06 '12 21:06

drbv


People also ask

How do I install an enchantment module in Python?

To install Enchant module, we can use the following command: ! pip3 install pyenchant.

What is PyEnchant in Python?

PyEnchant is a spellchecking library for Python, based on the excellent Enchant library. PyEnchant combines all the functionality of the underlying Enchant library with the flexibility of Python and a nice “Pythonic” object-oriented interface.


1 Answers

Enchant is 'lazy' and need backend support from aspell.

So, what you need to do is:

brew remove aspell
brew install aspell --lang=en

Then en dicts will be installed and so no need to download additional dicts.

like image 141
lxyu Avatar answered Sep 28 '22 09:09

lxyu