Hi all, I'm having trouble with getting hooks to work in --onefile mode 
with the sklearn library.  With the following simple Python script called 
test_project.py:

import sklearn.metrics.cluster

if __name__ == '__main__':
    print 'hey'

If I just run 
pyinstaller --onedir test_project.py
when running the binary I get the error

  File "_min_spanning_tree.pyx", line 8, in init 
sklearn.utils.mst._min_spanning_tree 
(sklearn/utils/sparsetools/_min_spanning_tree.c:4754)
ImportError: No module named _graph_validation

So, I created the file hook-sklearn.metrics.cluster.py in the same folder 
as test_project.py with the following contents:

hiddenimports = ['sklearn.utils.sparsetools._graph_validation',
                 'sklearn.utils.sparsetools._graph_tools',
                 'sklearn.utils.lgamma',
                 'sklearn.utils.weight_vector']

Then, if I run
pyinstaller --onedir --additional-hooks-dir=. test_project.py
it processes the additional hook correctly:

6598 INFO: Processing hook hook-sklearn.metrics.cluster

and the binary runs without issue.  However, if I run 
pyinstaller --onefile --additional-hooks-dir=. test_project.py
it still processes the hook correctly:

6583 INFO: Processing hook hook-sklearn.metrics.cluster

But when running the resulting binary, I get the same error as above, 
before including the additional hooks, as if the hooks were not processed:

  File "_min_spanning_tree.pyx", line 8, in init 
sklearn.utils.mst._min_spanning_tree 
(sklearn/utils/sparsetools/_min_spanning_tree.c:4754)
ImportError: No module named _graph_validation

Any tips on how to debug this?  This problem was also documented here by 
someone else but no solution was found:
http://stackoverflow.com/questions/20602721/pyinstaller-a-module-is-not-included-into-onefile-but-works-fine-with-oned

Thanks for any tips.

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

Reply via email to