python - pyenchant 在 Mac OS X 上找不到字典文件

标签 python installation pyenchant

我在运行 Lion 的 MacbookPro 上安装 pyenchant 时遇到问题。我使用 homebrew 和 pip 安装 enchant 和 pyenchant

homebrew install enchant

pip install pyenchant

我还下载了一本英语词典到以下文件夹:

/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

但是,当我尝试使用 enchant 时,出现以下错误。

>>> 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

我猜我没有将字典文件安装在正确的文件夹中,但我不知道在哪里安装它们。

谢谢。

最佳答案

Enchant 很“懒惰”,需要 aspell 的后端支持。

那么,你需要做的是:

brew remove aspell
brew install aspell --lang=en

然后将安装 en dicts,因此无需下载额外的 dicts。

关于python - pyenchant 在 Mac OS X 上找不到字典文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10922546/

相关文章:

python - 在 Falcon 框架中将所有路径路由到一个处理函数

python - BaseHTTPServer 无法识别 CSS 文件

windows - 使用 NSIS 复制目录。

python - PyEnchant:使用个人单词列表拼写检查文本 block

python - 无法在 OSX 上安装 pyenchant

java - 如何在后台使用PHP/HTML作为界面,使用Java/Python作为功能?

python - selenium.wait_for_condition 等效于 WebDriver 的 Python 绑定(bind)

installation - 从 Inno Setup 执行带有输出重定向的程序

installation - 如何使 Inno Setup RunList list 框透明?

python - 使用 pyenchant 时出错 : enchant_dict_check: assertion `g_utf8_validate(word, len, NULL)' failed