title: pyinstaller not working with lxml
body: <p>I am trying to create an exe using pyinstaller but keep running into this error</p>
  
  <pre><code>Traceback (most recent call last):
  File "runautojama.py", line 28, in &lt;module&gt;
  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 &lt;module&gt;
  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 &lt;module&gt;
  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
  </code></pre>
  
  <p>These are due to the import statements</p>
  
  <pre><code>from lxml import etree
  from lxml import html
  </code></pre>
  
  <p>I am using lxml==3.6.0</p>
  
  <p>I created hooks for lxml.etree like this</p>
  
  <pre><code>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'))
  </code></pre>
  
  <p>And a simple hook for lxml.html</p>
  
  <pre><code>from PyInstaller.utils.hooks import collect_submodules, get_module_file_attribute
  
  hiddenimports = collect_submodules('lxml.html')
  </code></pre>
  
  <p>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.</p>
  
  <p>My spec file:</p>
  
  <pre><code>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)
  </code></pre>