Hook works in --onedir but not in --onefile

377 views
Skip to first unread message

Colin Raffel

unread,
Aug 19, 2014, 2:08:44 PM8/19/14
to pyins...@googlegroups.com
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:

Thanks for any tips.

Hartmut Goebel

unread,
Aug 26, 2014, 4:29:36 AM8/26/14
to pyins...@googlegroups.com
Am 19.08.2014 20:08, schrieb Colin Raffel:
Any tips on how to debug this?

Have you already tried <http://www.pyinstaller.org/wiki/HowtoReportBugs#Beforesubmittingareport:Makesureeverythingispackaged>

--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP
Information Security Management, Security Governance, Secure Software Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/kritik-an-change.org-datensammler
Kolumne: http://www.cissp-gefluester.de/2011-02-fleisige-datensammler-fur-lukratives-geschaeftsmodell-gesucht

Goebel Consult ist Mitglied bei http://www.7-it.de/

chiyuan goh

unread,
Jan 1, 2015, 9:14:06 PM1/1/15
to pyins...@googlegroups.com
I had the same problem. The link is dead.....

Martin Zibricky

unread,
Jan 8, 2015, 9:23:43 AM1/8/15
to pyins...@googlegroups.com

We have migrated wiki to github and the structure is little different. See:

 

https://github.com/pyinstaller/pyinstaller/wiki/How-to-Report-Bugs#make-sure-everything-is-packaged-correctly

signature.asc
Reply all
Reply to author
Forward
0 new messages