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

6.4k views Asked by At
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?

1

There are 1 answers

1
durden2.0 On

The problem is skimage.transform requires on a small 'chain' of hidden imports. 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.

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.
  2. 'hook' files, which can help you group a few hidden imports based on what module requires them.

For example, for your specific situation you can create a file called hook-skimage.transform.py and put the following in it:

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. However, those specific hidden imports fixed my scenario on Windows 7 64-bit with skimage 0.9.3.

Then, tell pyinstaller where to look for your extra hook files. So, if you put the hook-skimage.transform.py file in your '.' directory you need to modify your pyinstaller build command to include --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.