title: Error when bundling application using pyinstaller (windows)
body: <p>I'm trying to bundle a quite extensive application that uses scikits-image/skimage, numpy, scipy, wx and reportlab. I'm on Windows 7 btw.</p>
  
  <p>It seems to build just fine:</p>
  
  <pre><code>1091 INFO: wrote C:\Users\IEUser\Desktop\pyinstaller\sasdm\sasdm.spec
  1200 INFO: Testing for ability to set icons, version resources...
  1923 INFO: ... resource update available
  1993 INFO: UPX is not available.
  12236 INFO: checking Analysis
  12246 INFO: building Analysis because out00-Analysis.toc non existent
  12246 INFO: running Analysis out00-Analysis.toc
  12256 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executabl
  e
  69579 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.2
  1022.8_none ...
  69589 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1f
  c8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest
  69640 INFO: Searching for file msvcr90.dll
  69650 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b
  _9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
  69650 INFO: Searching for file msvcp90.dll
  69660 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b
  _9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
  69660 INFO: Searching for file msvcm90.dll
  69660 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b
  _9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
  70089 INFO: Analyzing C:\Users\IEUser\Desktop\pyinstaller\support\_pyi_bootstrap
  .py
  72563 INFO: Analyzing C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\arc
  hive.py
  72713 INFO: Analyzing C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\car
  chive.py
  72864 INFO: Analyzing C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.
  py
  72904 INFO: Analyzing C:/Users/IEUser/Desktop/sasdm/sasdm.py
  90069 INFO: checking Tree
  90078 INFO: building because out00-Tree.toc missing or bad
  90078 INFO: building Tree out00-Tree.toc
  91530 INFO: checking Tree
  91530 INFO: building because out01-Tree.toc missing or bad
  91530 INFO: building Tree out01-Tree.toc
  98730 INFO: Hidden import 'encodings' has been found otherwise
  98742 INFO: Looking for run-time hooks
  98742 INFO: Analyzing rthook C:\Users\IEUser\Desktop\pyinstaller\support/rthooks
  /pyi_rth_Image.py
  98772 INFO: Analyzing rthook C:\Users\IEUser\Desktop\pyinstaller\support/rthooks
  /pyi_rth_PIL_Image.py
  98802 INFO: Analyzing rthook C:\Users\IEUser\Desktop\pyinstaller\support/rthooks
  /pyi_rth_Tkinter.py
  98911 INFO: Analyzing rthook C:\Users\IEUser\Desktop\pyinstaller\support/rthooks
  /pyi_rth_encodings.py
  100013 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of
   final executable
  123457 INFO: Warnings written to C:\Users\IEUser\Desktop\pyinstaller\sasdm\build
  \pyi.win32\sasdm\warnsasdm.txt
  123556 INFO: checking PYZ
  123556 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
  123556 INFO: building PYZ out00-PYZ.toc
  155382 INFO: checking PKG
  155393 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
  155393 INFO: building PKG out00-PKG.pkg
  199075 INFO: checking EXE
  199085 INFO: rebuilding out00-EXE.toc because sasdm.exe missing
  199085 INFO: building EXE from out00-EXE.toc
  199164 INFO: Appending archive to EXE C:\Users\IEUser\Desktop\pyinstaller\sasdm\
  dist\sasdm.exe
  </code></pre>
  
  <p>But when I try to run the application I am greeted with the following errors:</p>
  
  <pre><code>_MEIPASS2 is NULL
  archivename is C:\Users\IEUser\Desktop\pyinstaller\sasdm\dist\sasdm.exe
  Extracting binaries
  Executing self as child with Setting up to run child
  Creating child process
  Waiting for child process to finish...
  _MEIPASS2 is C:/Users/IEUser/AppData/Local/Temp/_MEI39282/
  archivename is C:\Users\IEUser\Desktop\pyinstaller\sasdm\dist\sasdm.exe
  Already in the child - running!
  manifestpath: C:/Users/IEUser/AppData/Local/Temp/_MEI39282/sasdm.exe.manifest
  Activation context created
  Activation context activated
  C:/Users/IEUser/AppData/Local/Temp/_MEI39282/python27.dll
  Manipulating evironment
  PYTHONPATH=C:/Users/IEUser/AppData/Local/Temp/_MEI39282;C:/Users/IEUser/Desktop/
  pyinstaller/sasdm/dist
  PYTHONHOME=C:/Users/IEUser/AppData/Local/Temp/_MEI39282/
  importing modules from CArchive
  extracted iu
  extracted struct
  extracted archive
  Installing import hooks
  out00-PYZ.pyz
  Running scripts
  Traceback (most recent call last):
    File "&lt;string&gt;", line 10, in &lt;module&gt;
    File "C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.py", line 386,
   in importHook
      mod = _self_doimport(nm, ctx, fqname)
    File "C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.py", line 480,
   in doimport
      exec co in mod.__dict__
    File "C:\Users\IEUser\Desktop\pyinstaller\sasdm\build\pyi.win32\sasdm\out00-PY
  Z.pyz\cell_analysis", line 13, in &lt;module&gt;
    File "C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.py", line 431,
   in importHook
      mod = self.doimport(nm, ctx, ctx + '.' + nm)
    File "C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.py", line 480,
   in doimport
      exec co in mod.__dict__
    File "C:\Users\IEUser\Desktop\pyinstaller\sasdm\build\pyi.win32\sasdm\out00-PY
  Z.pyz\skimage.data", line 11, in &lt;module&gt;
    File "C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.py", line 386,
   in importHook
      mod = _self_doimport(nm, ctx, fqname)
    File "C:\Users\IEUser\Desktop\pyinstaller\PyInstaller\loader\iu.py", line 480,
   in doimport
      exec co in mod.__dict__
    File "C:\Users\IEUser\Desktop\pyinstaller\sasdm\build\pyi.win32\sasdm\out00-PY
  Z.pyz\skimage.io", line 76, in &lt;module&gt;
    File "C:\Users\IEUser\Desktop\pyinstaller\sasdm\build\pyi.win32\sasdm\out00-PY
  Z.pyz\skimage.io", line 56, in _update_doc
  ValueError: max() arg is an empty sequence
  RC: -1 from sasdm
  OK.
  Deactivating activation context
  Releasing activation context
  Done
  Back to parent...
  Freeing status for C:\Users\IEUser\Desktop\pyinstaller\sasdm\dist\sasdm.exe
  </code></pre>
  
  <p>This leads me to believe that there's something wrong with skimage / scikits-image but I'm clueless about how to resolve this. Has anyone encountered anything similar?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I also tested this with py2exe and got the following sort of identical response:</p>
  
  <pre><code>Traceback (most recent call last):
    File "sasdm.py", line 10, in &lt;module&gt;
      import cell_analysis
    File "cell_analysis.pyc", line 13, in &lt;module&gt;
  
    File "skimage\data\__init__.pyc", line 11, in &lt;module&gt;
    File "skimage\io\__init__.pyc", line 76, in &lt;module&gt;
    File "skimage\io\__init__.pyc", line 56, in _update_doc
  ValueError: max() arg is an empty sequence
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>I've narrowed the problem down now. In skimage/io/_plugins/plugin.py, skimage will try to read its plugins from files in the following manner:</p>
  
  <pre><code>pd = os.path.dirname(__file__)
  ini = glob(os.path.join(pd, '*.ini'))
  </code></pre>
  
  <p>However, <strong>file</strong> evaluates to a non-existent (and seemingly randomly named) directory. Now, skimage needs it's plugin files (.ini and .py) to be included in the bundle and then when run, needs to look for them within the bundle. I guess the first bit could be done by collecting data files but the second part?</p>