简体   繁体   English

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

[英]Py2exe: Import error when executes created exe file

after creating an exe file, when i executes the following error.enchant is already installed in my system. 创建exe文件后,当我执行以下错误时。enchant已安装在我的系统中。 Im using anaconda. 我正在使用蟒蛇。 the build process run smoothly without any errors. 构建过程运行平稳,没有任何错误。

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.

my setup.py file is 我的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,
)

is this the right way to this? 这是正确的方法吗? Why does the import error happens ? 为什么会发生导入错误?

finally i got the answer from pyenchant documentation itself! 终于我从pyenchant文档本身得到了答案! To successfully package an application that uses PyEnchant, these auxilliary files must be explicitly included in the “data_files” argument to the setup function. 要成功打包使用PyEnchant的应用程序,必须在安装函数的“ data_files”参数中明确包含这些辅助文件。 The function enchant.utils.win32_data_files returns a list of files which can be used for this purpose. 函数enchant.utils.win32_data_files返回可用于此目的的文件列表。 add this to setup 将此添加到设置

   data_files=enchant.utils.win32_data_files()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM