2012-06-06 16 views
5

Ho problemi a installare Pyenchant su un MacbookPro con Lion in esecuzione. Ho usato homebrew e pip da installare incantare e pyenchantpyenchant non riesce a trovare il dizionario su Mac OS X

homebrew installare incantare

pip install pyenchant

Ho scaricato anche un dizionario di inglese nella seguente cartella:

/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 

Tuttavia, quando provo a utilizzare enchant, ottengo il seguente errore.

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

sto cercando di indovinare che non ho i file dizionario installati nella cartella corretta, ma non so dove altro installarli.

Grazie.

risposta

6

Enchant è "pigro" e necessita del supporto di backend da aspell.

Allora, che cosa dovete fare è:

brew remove aspell 
brew install aspell --lang=en 

Poi en dicts verrà installato e quindi non è necessario scaricare dicts supplementari.

0

sono stato in grado di risolvere questo usando il comando:

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

Altre persone che avevano installato incantesimo usando le porte non avevano questo problema.

1

Sono stato anche in grado di risolvere impostando esplicitamente il parametro per il percorso del dizionario. Non ho installato brew - sto usando le porte mac. Dovuto scaricare manualmente il file OXT da Apache open office ed estrarre i file da esso (dopo la ridenominazione .oxt a .zip dove sono questi valori del percorso di default memorizzati

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 

Ora ho applicato la correzione utilizzando le mie specifiche filesystem:.?

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

Vedere per credere - ancora una volta - dove si trova la versione di default di questo percorso memorizzato (io sono un newby a Python e le uova - proviene da Java e vasetti)