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

后端 未结 1 1445
攒了一身酷
攒了一身酷 2021-01-25 00:03
Traceback (most recent call last):
 File \"\", line 1, in 
File py_installer/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py\", line 270,         


        
相关标签:
1条回答
  • 2021-01-25 00:40

    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.

    0 讨论(0)
提交回复
热议问题