Pyinstaller - WindowsError: [错误 126] 找不到指定的模块 [英] Pyinstaller - WindowsError: [Error 126] The specified module could not be found

查看:78
本文介绍了Pyinstaller - WindowsError: [错误 126] 找不到指定的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好博学的读者,

我在使用 pyinstaller 创建 exe 时遇到了一些问题,因此在运行时,我收到了错误消息:

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

据我所知,这是一个 dll 问题.但是,它没有指定哪一次导致了问题.我已经使用 --log-level=debug 进行了调试并将其粘贴在下面.我还检查了来自 pyinstaller 的警告消息,但无法确定错误原因.

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?

非常感谢

从构建时的输出中截取的片段:

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

推荐答案

问题是 geos_c.dll 文件.Pyinstaller 没有自动选择它.我尝试将其复制到从中执行规范文件的构建目录.然而,这还不够,解决方案是编辑规范文件以包含 geos_c.dll

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 )

这篇关于Pyinstaller - WindowsError: [错误 126] 找不到指定的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆