I am trying to create an exe using pyinstaller but keep running into this error
Traceback (most recent call last):
File "runautojama.py", line 28, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "autogen\jama_lib.py", line 24, in <module>
from lxml import html as htmlLib
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\lxml\html\__init__.py", line 54, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 546, in load_module
module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
Failed to execute script runautojama
These are due to the import statements
from lxml import etree
from lxml import html
I am using lxml==3.6.0
I created hooks for lxml.etree like this
import os.path
import glob
from PyInstaller.compat import EXTENSION_SUFFIXES
from PyInstaller.utils.hooks import collect_submodules, get_module_file_attribute
hiddenimports = collect_submodules('lxml')
binaries = []
lxml_dir = os.path.dirname(get_module_file_attribute('lxml'))
for ext in EXTENSION_SUFFIXES:
lxmlMods = glob.glob(os.path.join(lxml_dir, '*%s*' % ext))
for f in lxmlMods:
binaries.append((f, 'lxml'))
And a simple hook for lxml.html
from PyInstaller.utils.hooks import collect_submodules, get_module_file_attribute
hiddenimports = collect_submodules('lxml.html')
It copies the etree.pyd and other pyd's to the path but it still doesnt seem to work and I still get the same error. Can you suggest what I might be doing wrong.
My spec file:
a = Analysis(['..\\runautojama.py'],
pathex=['scripts\\pyinstallerfiles'],
binaries=None,
datas=None,
hiddenimports=['collections', 'urlparse', 'lxml._elementpath', 'functools', '__future__', 'gzip', 'lxml.html', 'lxml.includes'],
hookspath=['scripts\pyinstallerfiles\hooks'],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)