2012-06-06 15 views
5

Tengo problemas para instalar pyenchant en MacbookPro ejecutando Lion. He usado homebrew y PIP para instalar encantamiento y pyenchantpyenchant no puede encontrar el archivo de diccionario en Mac OS X

homebrew instalo encantamiento

pip instalación pyenchant

También he descargado un diccionario Inglés a la siguiente carpeta:

/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 

Sin embargo, cuando intento usar encantamiento, aparece el siguiente error.

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

supongo que no tengo instalados en la carpeta correcta de los archivos de diccionario, pero no sé dónde más instalarlos.

Gracias.

Respuesta

6

Encantar es 'flojo' y necesita soporte de backend de aspell.

Por lo tanto, lo que hay que hacer es:

brew remove aspell 
brew install aspell --lang=en 

Entonces es predice será instalado y por lo que no hay necesidad de descargar predice adicionales.

0

que era capaz de resolver esto utilizando el comando:

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

Otras personas que se habían instalado encantamiento utilizando puertos no tienen este problema.

1

También pude resolver estableciendo explícitamente el parámetro para la ruta del diccionario. No tengo la infusión instalada, estoy usando puertos Mac. Tuvieron que descargar manualmente el archivo oxt de la oficina abierta Apache y extraer los archivos de ella (después de cambiar el nombre de .oxt a .zip dónde se almacenan estos valores de las rutas por defecto

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 

Ahora aplicar el arreglo mediante mis características específicas del sistema de archivos:.?

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

Ver para creer - una vez más - ¿dónde está la versión predeterminada de este camino almacenado (soy un Newby a Python y huevos - viene de Java y tarros)