pyenchant can't find dictionary file on Mac OS X

前端 未结 3 1381
灰色年华
灰色年华 2021-01-18 17:19

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

homebrew install ench

相关标签:
3条回答
  • 2021-01-18 17:55

    I was able to solve this using the command:

    enchant.set_param("enchant.myspell.dictionary.path", "/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/enchant/share/enchant/myspell")

    Other people who had installed enchant using ports did not have this issue.

    0 讨论(0)
  • 2021-01-18 18:04

    I also was able to solve by explicitly setting the parameter for the dictionary path. Don't have brew installed - am using mac ports. Had to manually download the oxt file from apache open office and extract the files from it (after renaming .oxt to .zip . Where are these default path values stored?

    Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)   
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin  
    Type "help", "copyright", "credits" or "license" for more information.  
    >>>  
    >>> import enchant  
    >>> d = enchant.Dict("en_US")  
    Traceback (most recent call last):  
      File "<stdin>", line 1, in <module>  
      File "/Library/Python/2.7/site-packages/pyenchant-1.6.5-py2.7.egg/enchant/__init__.py", line 502,   in __init__  
        self._switch_this(broker._request_dict_data(tag),broker)   
      File "/Library/Python/2.7/site-packages/pyenchant-1.6.5-py2.7.egg/enchant/__init__.py", line 264, 
      in _request_dict_data  
        self._raise_error(eStr % (tag,),DictNotFoundError)  
      File "/Library/Python/2.7/site-packages/pyenchant-1.6.5-py2.7.egg/enchant/__init__.py", line 218,   in _raise_error  
        raise eclass(default)  
    enchant.errors.DictNotFoundError: Dictionary for language 'en_US' could not be found  
    

    Now I apply the fix using my filesystem specifics:

    >>> enchant.set_param("enchant.myspell.dictionary.path","/Library/Python/2.7/site-packages/pyenchant-1.6.5-py2.7.egg/enchant/share/enchant/myspell")  
    >>> d=enchant.Dict("en_US")
    >>> d.check("enchant")  
    True  
    >>>   
    

    Seeing is believing - again - where is the default version of this path stored (I am a newby to Python and Eggs - coming from Java and Jars)

    0 讨论(0)
  • 2021-01-18 18:08

    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.

    0 讨论(0)
提交回复
热议问题