简体   繁体   English

ImportError:运行从pyinstaller获得的可执行文件时,没有名为几何的模块

[英]ImportError: No module named geometry while running executables obtained from pyinstaller

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

I have been getting above error. 我一直在出错。 Could some one please tell me how would i fix it? 有人可以告诉我如何解决吗?

The problem is skimage.transform requires on a small 'chain' of hidden imports . 问题是skimage.transform需要一小部分隐藏的导入链。 These are imports that happen in a variety of ways Pyinstaller cannot detect automatically, namely using __import__ , etc. So, you must tell Pyinstaller directly about these imports so it knows to inspect them and add them to your build. 这些导入以多种方式发生,Pyinstaller无法自动检测,即使用__import__等。因此,您必须将这些导入直接告知Pyinstaller,以便知道检查它们并将其添加到构建中。

You can do this in two ways: 您可以通过两种方式执行此操作:

  1. The --hidden-import command-line flag, which is useful if you have only a few modules to specify. --hidden-import命令行标志,如果您只需要指定几个模块,则很有用。
  2. 'hook' files, which can help you group a few hidden imports based on what module requires them. “ hook”文件,可以帮助您根据需要的模块将一些隐藏的导入分组。

For example, for your specific situation you can create a file called hook-skimage.transform.py and put the following in it: 例如,对于您的特定情况,您可以创建一个名为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']

You may not need all of those modules specified. 您可能不需要所有指定的模块。 Your build was only lacking skimage._shared.geometry so you could try only including that file with the --hidden-import command-line flag, or only including skimage._shared.geometry in your hook-skimage.transform.py file. 您的构建仅缺少skimage._shared.geometry,因此您可以尝试仅使用--hidden-import命令行标志包括该文件,或者仅在hook-skimage.transform.py文件中包括skimage._shared.geometry。 However, those specific hidden imports fixed my scenario on Windows 7 64-bit with skimage 0.9.3. 但是,这些特定的隐藏导入将我的方案固定在带有skimage 0.9.3的Windows 7 64位上。

Then, tell pyinstaller where to look for your extra hook files. 然后,告诉pyinstaller在哪里寻找额外的钩子文件。 So, if you put the hook-skimage.transform.py file in your '.' 因此,如果将hook-skimage.transform.py文件放在“。”中 directory you need to modify your pyinstaller build command to include --additional-hooks-dir=. 您需要修改pyinstaller build命令以包含--additional-hooks-dir=.

This will cause pyinstaller to inspect the modules you specified when it tries to import skimage.transform.hough_line as your output mentioned. 当pyinstaller尝试导入skimage.transform.hough_line作为您提到的输出时,这将导致pyinstaller检查您指定的模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM