ImportError:没有名为typedefs的模块

时间:2015-03-12 08:30:20

标签: python scikit-learn pyinstaller

我正在尝试使用pyinstaller创建一个独立的程序。在此过程中,我遇到以下错误消息:

`Traceback (most recent call last):
File "<string>", line 13, in <module>
File "/opt/local/anaconda/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
File "/home/russellb/pyFiles/dist/build/tt/out00-PYZ.pyz/sklearn.neighbors", line 6, in <module>
File "/opt/local/anaconda/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 409, in load_module
    module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
File "dist_metrics.pxd", line 48, in init sklearn.neighbors.ball_tree (sklearn/neighbors/ball_tree.c:34295)
File "/opt/local/anaconda/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 409, in load_module
    module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
File "dist_metrics.pyx", line 52, in init sklearn.neighbors.dist_metrics (sklearn/neighbors/dist_metrics.c:25494)
  ImportError: No module named typedefs`

有什么建议吗?

作为后续行动:

我设法导入了typedef并摆脱了上述问题。现在我在运行时遇到以下错误消息。

Traceback (most recent call last): File "<string>", line 14, in <module> File "/opt/local/anaconda/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "/home/russellb/pyFiles/dist/build/tt/out00-PYZ.pyz/sklearn.linear_model", line 21, in <module> File "/opt/local/anaconda/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 409, in load_module module = imp.load_module(fullname, fp, filename, self._c_ext_tuple) File "weight_vector.pxd", line 10, in init sklearn.linear_model.sgd_fast (sklearn/linear_model/sgd_fast.c:9464) ImportError: No module named weight_vector

但是,我在指定位置的sklearn目录层次结构中找不到任何名为weight_vector的模块。

有任何见解和建议吗?

非常感谢,

2 个答案:

答案 0 :(得分:2)

我使用了auto-py-to-exe工具。这是一个gui工具,可在内部调用pyinstaller。 在高级选项中,我添加了--hidden-import所有缺少的模块。 在命令行中,我看到了所有模块作为参数:

--hidden-import sklearn.neighbors.typedefs --hidden-import sklearn.neighbors.quad_tree --hidden-import sklearn.tree._utils

enter image description here

答案 1 :(得分:0)

您可以将--hidden-import = modulename添加到pyinstaller脚本中。它将导入此模块并绑定。