ImportError:运行从 pyinstaller 获取的可执行文件时没有名为 Geometry 的模块

2023-12-03

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 需要一个小的“链”隐藏进口。这些导入以 Pyinstaller 无法自动检测的多种方式发生,即使用__import__因此,您必须直接告诉 Pyinstaller 有关这些导入的信息,以便它知道检查它们并将它们添加到您的构建中。

您可以通过两种方式执行此操作:

  1. --hidden-import 命令行标志,如果您只有几个模块需要指定,则该标志非常有用。
  2. “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 构建命令以包含的目录--additional-hooks-dir=.

这将导致 pyinstaller 在尝试导入 skimage.transform.hough_line 作为您提到的输出时检查您指定的模块。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ImportError:运行从 pyinstaller 获取的可执行文件时没有名为 Geometry 的模块 的相关文章

随机推荐