Py2exe:执行创建的exe文件时导入错误

Py2exe: Import error when executes created exe file

创建 exe 文件后,当我执行以下命令时 error.enchant 已经安装在我的系统中。我正在使用蟒蛇。构建过程 运行 顺利,没有任何错误。

Traceback (most recent call last):
File "ocropus-rpred.py", line 5, in <module>
File "enchant\__init__.pyo", line 92, in <module>
File "enchant\_enchant.pyo", line 143, in <module>
ImportError: The 'enchant' C library was not found. Please install it 
via   your OS package manager, or use a pre-built binary wheel from PyPI.

我的 setup.py 文件是

from distutils.core import setup
import py2exe,sys
import enchant
print  sys.setrecursionlimit(10000)
includes = [ "enchant"]

options = {"py2exe": {"optimize": 2,"includes": includes, }}
setup(console=['ocr/ocropus-rpred.py'],
options = options,
)

这是正确的方法吗?为什么会出现导入错误?

最后我从 pyenchant 文档本身得到了答案! 要成功打包使用 PyEnchant 的应用程序,这些辅助文件必须明确包含在设置函数的“data_files”参数中。函数 enchant.utils.win32_data_files returns 可用于此目的的文件列表。将此添加到设置

   data_files=enchant.utils.win32_data_files()