I'm using PyInstaller to bundle my application into one .exe file. The problem is that it works fine with --onedir option, but can't find a module when built with --onefile.
Both --onedir and --onefile say during the building process:
<...>
INFO: Analyzing hidden import 'sklearn.utils.sparsetools._graph_validation'
<...>
Running the instance created with --onedir works fine, but the instance produced by --onefile dies:
<...>
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
Here are my .spec files
onedir.spec
# -*- mode: python -*-
a = Analysis(['../../brainactivity.py'],
hiddenimports=['greenlet', 'sklearn.utils.sparsetools._graph_validation', 'sklearn.utils.sparsetools._graph_tools', 'scipy.special._ufuncs_cxx', 'sklearn.utils.lgamma', 'sklearn.utils.weight_vector'],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='brainactivity.exe',
debug=False,
strip=None,
upx=True,
console=True,)
coll = COLLECT(exe,
a.binaries,
[('./data/201305182224-DF-facial-3-420.csv', '../../data/201305182224-DF-facial-3-420.csv', 'DATA')],
[('./model/brain_20k_colored_properly.obj', '../../model/brain_20k_colored_properly.obj', 'DATA')],
[('brain_fragment_shader.glsl', '../../brain_fragment_shader.glsl', 'DATA')],
[('brain_vertex_shader.glsl', '../../brain_vertex_shader.glsl', 'DATA')],
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='brainactivity')
onefile.spec
# -*- mode: python -*-
a = Analysis(['../../brainactivity.py'],
hiddenimports=['greenlet', 'sklearn.utils.sparsetools._graph_validation', 'sklearn.utils.sparsetools._graph_tools', 'scipy.special._ufuncs_cxx', 'sklearn.utils.lgamma', 'sklearn.utils.weight_vector'],
hookspath='.',
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
[('./data/201305182224-DF-facial-3-420.csv', '../../data/201305182224-DF-facial-3-420.csv', 'DATA')],
[('./model/brain_20k_colored_properly.obj', '../../model/brain_20k_colored_properly.obj', 'DATA')],
[('brain_fragment_shader.glsl', '../../brain_fragment_shader.glsl', 'DATA')],
[('brain_vertex_shader.glsl', '../../brain_vertex_shader.glsl', 'DATA')],
a.zipfiles,
a.datas,
name='brainactivity.exe',
debug=False,
strip=None,
upx=True,
console=True )