", li...">

ImportError: no module named geometry when running executable files 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 get the error above. Can someone please tell me how can I fix this?

+1
source share
1 answer

The skimage.transform problem requires a small β€œchain” of hidden imports . This is an import that occurs in many ways. Pyinstaller cannot automatically detect, namely with __import__ , etc. So, you should tell Pyinstaller directly about these importers so that it knows, to check them and add them to your assembly.

You can do this in two ways:

  • The command line flag is hidden-import, which is useful if you have only a few modules to indicate.
  • 'hooks' that can help you group multiple hidden imports based on what a module is required for them.

For example, for your specific situation, you can create a hook-skimage.transform.py file 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 these modules. Your assembly lacked skimage._shared.geometry, so you could only try to include this file with the -hidden-import command line flag or only include the skimage._shared.geometry file in hook-skimage.transform.py. However, these specific hidden imports fixed my script on a 64-bit version of Windows 7 with a resolution of 0.9.3.

Then tell pyinstaller where to look for additional hook files. So, if you put the hook-skimage.transform.py file in your '.' you need to modify the pyinstaller build command to include --additional-hooks-dir=.

This will cause pyinstaller to check the modules you specified when you tried to import skimage.transform.hough_line as the output you mentioned.

+5
source

All Articles