Traceback (most recent call last):
File "<string>", line 1, in <module>
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File py_installer/PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/proj_code", line 11, in <module>
File PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/skimage.transform", line 1, in <module>
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File py_installer/PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/skimage.transform.hough_transform", line 7, in <module>
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 409, in load_module
File "_hough_transform.pyx", line 13, in init skimage.transform._hough_transform (skimage/transform/_hough_transform.c:7337)
File "py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File "py_installer/PyInstaller-2.1/FaceMatcher/build/FaceMatcher/out00-PYZ.pyz/skimage.draw", line 1, in <module>
File "py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 409, in load_module
File "_draw.pyx", line 1, in init skimage.draw._draw (skimage/draw/_draw.c:7257)
ImportError: No module named geometry
我一直在出错。有人可以告诉我如何解决吗?
最佳答案
问题是skimage.transform需要hidden imports的小“链”。这些导入以各种方式发生,Pyinstaller无法自动检测,即使用__import__
等。因此,您必须将这些导入直接告知Pyinstaller,以便它知道对其进行检查并将其添加到构建中。
您可以通过两种方式执行此操作:
--hidden-import命令行标志,如果您只需要指定几个模块,则很有用。
“ hook”文件,可以帮助您根据需要的模块将一些隐藏的导入分组。
例如,对于您的特定情况,您可以创建一个名为hook-skimage.transform.py的文件,并将以下内容放入其中:
hiddenimports = ['skimage.draw.draw',
'skimage.draw._draw',
'skimage.draw.draw3d',
'skimage._shared.geometry',
'skimage._shared.interpolation',
'skimage.filter.rank.core_cy']
您可能不需要所有指定的模块。您的构建仅缺少skimage._shared.geometry,因此您可以尝试仅通过--hidden-import命令行标志包括该文件,或者仅在hook-skimage.transform.py文件中包括skimage._shared.geometry。但是,这些特定的隐藏导入将我的方案固定在带有skimage 0.9.3的Windows 7 64位上。
然后,告诉pyinstaller在哪里寻找额外的钩子文件。因此,如果将hook-skimage.transform.py文件放在“。”中您需要修改pyinstaller build命令以包含
--additional-hooks-dir=.
的目录这将导致pyinstaller在尝试导入skimage.transform.hough_line作为您提到的输出时检查您指定的模块。