Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use py2exe when it include sklearn?

Tags:

python

py2exe

if the code has import sklearn, after use py2exe

then run the "exe" file, I got this error log:

Traceback (most recent call last):
File "HelloSklearn.py", line 17, in <module>
File "sklearn\__init__.pyc", line 32, in <module>
File "sklearn\base.pyc", line 8, in <module>
File "scipy\sparse\__init__.pyc", line 191, in <module>
File "scipy\sparse\csgraph\__init__.pyc", line 146, in <module>
File "scipy\sparse\csgraph\_shortest_path.pyc", line 12, in <module>
File "scipy\sparse\csgraph\_shortest_path.pyc", line 10, in __load
File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path(scipy\sparse\csgraph\_shortest_path.c:14235)
ImportError: No module named _validation
like image 831
user1843846 Avatar asked Oct 05 '22 21:10

user1843846


1 Answers

You can either add scipy.sparse.csgraph._validation to the includes option in your setup.py script

setup( 
    ...
    options = { 'includes': ['scipy.sparse.csgraph._validation'] }
)

or just force py2exe to spot it by forcing an import - somewhere in your code put

import scipy.sparse.csgraph._validation
like image 132
danodonovan Avatar answered Oct 10 '22 13:10

danodonovan