2012-06-06 37 views
5

Tôi gặp sự cố khi cài đặt pyenchant trên MacbookPro đang chạy Lion. Tôi đã sử dụng homebrew và pip để cài đặt enchant và pyenchantpyenchant không thể tìm thấy tệp từ điển trên Mac OS X

homebrew cài đặt enchant

pips cài đặt pyenchant

Tôi cũng đã tải về một cuốn từ điển tiếng Anh vào thư mục sau:

/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 

Tuy nhiên, khi tôi cố gắng sử dụng enchant, tôi nhận được lỗi sau.

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

Tôi đoán tôi không cài đặt tệp từ điển vào đúng thư mục nhưng tôi không biết nơi nào khác để cài đặt chúng.

Cảm ơn.

Trả lời

6

Enchant là 'lười' và cần hỗ trợ phụ trợ từ aspell.

Vì vậy, những gì bạn cần làm là:

brew remove aspell 
brew install aspell --lang=en 

Sau đó en dicts sẽ được cài đặt và vì vậy không cần phải tải về dicts bổ sung.

0

tôi đã có thể giải quyết việc này bằng cách sử dụng lệnh:

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

Những người khác đã cài đặt cổng enchant bằng cách sử dụng không có vấn đề này.

1

Tôi cũng có thể giải quyết bằng cách đặt thông số rõ ràng cho đường dẫn từ điển. Không có brew được cài đặt - đang sử dụng cổng mac. Phải tự tải file oxt từ mở văn phòng apache và trích xuất các tập tin từ nó (sau khi đổi tên .oxt để .zip đâu các giá trị đường dẫn mặc định lưu trữ

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 

Bây giờ tôi xin sửa chữa sử dụng chi tiết cụ thể hệ thống tập tin của tôi:.?

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

Thấy mới tin - một lần nữa - nơi là phiên bản mặc định của con đường này được lưu trữ (tôi là một newby để Python và Trứng - đến từ Java và Chum)