2012-06-06 93 views
5

我在運行Lion的MacbookPro上安裝pyenchant時遇到問題。我用自制和PIP安裝附魔和pyenchantpyenchant在Mac OS X上找不到字典文件

自制安裝附魔

PIP安裝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 
[email protected] 1 mycomputer staff 1017 May 4 2007 README_en_US.txt 
[email protected] 2 mycomputer staff  68 Jun 6 13:38 en_US 
[email protected] 1 mycomputer staff 3045 May 4 2007 en_US.aff 
[email protected] 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 

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

謝謝。

回答

6

附魔是'懶惰',需要aspell支持後端。

所以,你需要做的是:

brew remove aspell 
brew install aspell --lang=en 

然後連接類型的字典將被安裝,因此無需下載其他類型的字典。

0

我能解決這個使用下面的命令:

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

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

1

我也可以通過明確設置字典路徑的參數來解決。沒有安裝brew - 我正在使用mac端口。只好手工下載Apache的開放式辦公的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 
>>> 

百聞不如一見 - 再 - 在哪裏存儲這個路徑的默認版本 -

(我是一個牛逼到Python和雞蛋從Java和罐子來)