簡體   English   中英

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

[英]pyenchant can't find dictionary file on Mac OS X

我在運行Lion的MacbookPro上安裝pyenchant時遇到了麻煩。 我用自制軟件和點子來安裝附魔和詭計

自制軟件安裝附魔

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

但是,當我嘗試使用附魔時,我收到以下錯誤。

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

我猜我沒有在正確的文件夾中安裝字典文件,但我不知道在哪里安裝它們。

謝謝。

附魔是'懶惰',需要來自aspell的后端支持。

那么,你需要做的是:

brew remove aspell
brew install aspell --lang=en

然后將安裝en dicts,因此無需下載其他dicts。

我還能夠通過顯式設置字典路徑的參數來解決。 沒有安裝brew - 我正在使用mac端口。 不得不從apache open office手動下載oxt文件並從中提取文件(在將.oxt重命名為.zip 。這些默認路徑值存儲在哪里?

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  

現在我使用我的文件系統細節來應用修復:

>>> 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相信 - 再次 - 存儲此路徑的默認版本(我是Python和Eggs的新手 - 來自Java和Jars)

我能夠使用命令解決這個問題:

enchant.set_param(“enchant.myspell.dictionary.path”,“/ usr / local / Cellar / python / 2.72 / lib / python2.7 / site-package / enchant / share / enchant / myspers”)

其他使用端口安裝附魔的人沒有這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM