Py2exe: Import error when executes created exe file

225 views Asked by At

after creating an exe file, when i executes the following error.enchant is already installed in my system. 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

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 ?

1

There are 1 answers

0
Ananthakrishnan   M A On BEST ANSWER

finally i got the answer from pyenchant documentation itself! To successfully package an application that uses PyEnchant, these auxilliary files must be explicitly included in the “data_files” argument to the setup function. The function enchant.utils.win32_data_files returns a list of files which can be used for this purpose. add this to setup

   data_files=enchant.utils.win32_data_files()