Pyinstaller - WindowsError: [Error 126] The specified module could not be found

Deadly 提交于 2019-12-08 08:45:38

问题


Hello learned readers,

I'm having some trouble creating an exe using pyinstaller, whereby during run time, I'm receiving the error message:

  File "<string>", line 17, in <module>
  File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\shapely.geometry", line 4, in <module>
  File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\shapely.geometry.base", line 9, in <module>
  File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\shapely.coords", line 8, in <module>
  File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\shapely.geos", line 15, in <module>
  File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\shapely.libgeos", line 184, in <module>
  File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\ctypes", line 365, in __init__
WindowsError: [Error 126] The specified module could not be found

As far as I know, this is a dll problem. However it does not specify which once is causing the problem. I've debugged using --log-level=debug and pasted this below. I've also checked the warning message from pyinstaller and haven't been able to discern the cause of the error.

Any thought of suggestions as to what could be causing this error?

Many thanks

Snip taken from the output of the buildtime:

24094 INFO: Adding Microsoft.VC90.MFC to dependent assemblies of final executable
24222 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
24223 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86.manifest
24223 INFO: Searching for file mfc90.dll
24225 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfc90.dll
24225 INFO: Searching for file mfc90u.dll
24225 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfc90u.dll
24225 INFO: Searching for file mfcm90.dll
24225 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfcm90.dll
24225 INFO: Searching for file mfcm90u.dll
24225 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfcm90u.dll
26147 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_none ...
26147 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57.manifest
26148 INFO: Searching for file msvcr90.dll
26148 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll
26148 INFO: Searching for file msvcp90.dll
26148 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcp90.dll
26149 INFO: Searching for file msvcm90.dll
26149 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcm90.dll
26516 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
27055 INFO: Using Python library C:\Windows\system32\python27.dll
27253 INFO: Warnings written to C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\warngis_helper2.txt
27286 INFO: checking PYZ
27286 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
27286 INFO: building PYZ (ZlibArchive) out00-PYZ.toc
33585 INFO: checking PKG
33585 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
33585 INFO: building PKG (CArchive) out00-PKG.pkg
60197 INFO: checking EXE
60197 INFO: rebuilding out00-EXE.toc because GIS_Helper.exe missing
60197 INFO: building EXE from out00-EXE.toc
60202 INFO: Appending archive to EXE C:\Users\Hp\PycharmProjects\GISdev\dist\GIS_Helper.exe

回答1:


The problem was the geos_c.dll file. Pyinstaller was not picking it up automatically. I tried copying this to the build directory where the spec file was being executed from. This wasn't enough however and the solution was to edit the spec file to include the geos_c.dll

# -*- mode: python -*-
a = Analysis(['GIS_Helper.py'],
             pathex=['C:\\Users\\Hp\\PycharmProjects\\GISdev'],
             hiddenimports=['scipy.linalg.cython_blas', 'scipy.linalg.cython_lapack', 'scipy.special._ufuncs_cxx', 'multiprocessing', '_multiprocessing', 'multiprocessing.process', 'multiprocessing.util', 'ctypes.util', 'pandas.util', 'distutils.util', 'shapely'],
             hookspath=None,
             runtime_hooks=None)



a.binaries=['geos_c.dll', 'geos_c.dll', 'BINARY'],

pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          [('v',None,'OPTION')],
          a.binaries,
          a.zipfiles,
          a.datas,
          name='GIS_Helper.exe',
          debug=True,
          strip=None,
          upx=True,
          console=True )


来源:https://stackoverflow.com/questions/32669161/pyinstaller-windowserror-error-126-the-specified-module-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!