Repository: pyinstaller/pyinstaller

Issue:
Missing skimage dependency: ImportError: No module named core_cy
Executing a script that imports the following:

```
import argparse
import json
import logging
import os.path
import sys
import tempfile
from collections import deque
from contextlib import contextmanager
from copy import deepcopy
from math import ceil
from multiprocessing.pool import ThreadPool
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
import time
from mpl_toolkits.mplot3d import Axes3D
from scipy.io import savemat, loadmat
from scipy.linalg import eigh, LinAlgError
from skimage.exposure import exposure
from skimage.feature import hog
from sklearn.metrics import f1_score
    from progress.bar import Bar
    from scipy.ndimage import morphology
    from scipy.signal import lfilter
            from sklearn.semi_supervised import label_propagation
        import coloredlogs
```

I get the following error at runtime: 

```
Traceback (most recent call last):
  File "<string>", line 22, in <module>
  File "C:\Users\ncgalopp\AppData\Local\Continuum\Anaconda\envs\vidsum\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 382, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\skimage\feature\__init__.py", line 5, in <module>
  File "C:\Users\ncgalopp\AppData\Local\Continuum\Anaconda\envs\vidsum\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 382, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\skimage\feature\peak.py", line 3, in <module>
  File "C:\Users\ncgalopp\AppData\Local\Continuum\Anaconda\envs\vidsum\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 382, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\skimage\filters\__init__.py", line 13, in <module>
  File "C:\Users\ncgalopp\AppData\Local\Continuum\Anaconda\envs\vidsum\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 382, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\skimage\filters\rank\__init__.py", line 1, in <module>
  File "C:\Users\ncgalopp\AppData\Local\Continuum\Anaconda\envs\vidsum\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 382, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\skimage\filters\rank\generic.py", line 24, in <module>
  File "C:\Users\ncgalopp\AppData\Local\Continuum\Anaconda\envs\vidsum\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 539, in load_module
    module = imp.load_module(fullname, fp, filename, ext_tuple)
  File "skimage\filters\rank\generic_cy.pyx", line 1, in init skimage.filters.rank.generic_cy (skimage\filters\rank\generic_cy.c:66519)
ImportError: No module named core_cy
vidsum returned -1
```

Version information:

```
35 INFO: PyInstaller: 3.1.dev0+84574d7
36 INFO: Python: 2.7.11
37 INFO: Platform: Windows-7-6.1.7601-SP1
```



Discussion:
@ngaloppo Could you for better reproducibility track down you example to the oneline import statement that's causing this error?


Resolving patch:
diff --git a/PyInstaller/hooks/hook-skimage.transform.py b/PyInstaller/hooks/hook-skimage.transform.py
--- a/PyInstaller/hooks/hook-skimage.transform.py
+++ b/PyInstaller/hooks/hook-skimage.transform.py
@@ -6,11 +6,12 @@
 #
 # The full license is in the file COPYING.txt, distributed with this software.
 #-----------------------------------------------------------------------------
-
+from PyInstaller.utils.hooks import collect_data_files
 
 # Hook tested with scikit-image (skimage) 0.9.3 on Mac OS 10.9 and Windows 7
 # 64-bit
 hiddenimports = ['skimage.draw.draw',
                  'skimage._shared.geometry',
-                 'skimage._shared.interpolation',
-                 'skimage.filter.rank.core_cy']
+                 'skimage.filters.rank.core_cy']
+
+datas = collect_data_files('skimage')
diff --git a/PyInstaller/hooks/hook-sklearn.metrics.cluster.py b/PyInstaller/hooks/hook-sklearn.metrics.cluster.py
new file mode 100644
--- /dev/null
+++ b/PyInstaller/hooks/hook-sklearn.metrics.cluster.py
@@ -0,0 +1,14 @@
+#-----------------------------------------------------------------------------
+# Copyright (c) 2014, PyInstaller Development Team.
+#
+# Distributed under the terms of the GNU General Public License with exception
+# for distributing bootloader.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+# Tested on Windows 7 64bit with scikit-learn 0.17 and Python 2.7
+hiddenimports = ['sklearn.utils.sparsetools._graph_validation',
+                 'sklearn.utils.sparsetools._graph_tools',
+                 'sklearn.utils.lgamma',
+                 'sklearn.utils.weight_vector']


Test patch: