python - Python 3.6 上的 Pyinstaller 和 Tensorflow 打包问题 (_pywrap_tensorflow_internal)
问题描述
我曾在 Windows 10 上将 Pyinstaller (3.4) 与 python 3.6 一起使用过,但这次我遇到了模块 _pywrap_tensorflow_internal (tensorflow-gpu 1.12) 的问题。该程序在生成它的计算机上完美运行,但在其他计算机(具有相同操作系统版本)上存在路径问题。
我发现一些线程(Tensorflow-gpu with pyinstaller、Windows 10 pyinstaller tensorflow missing modules、https://github.com/pyinstaller/pyinstaller/issues/3754)讨论了类似的问题,但建议的解决方案不适用于我的情况.
起初我收到以下错误:
回溯(最后一次调用):文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper 文件“imp.py”,第 297 行,在 find_module ImportError:没有名为 '_pywrap_tensorflow_internal' 的模块
在处理上述异常的过程中,又出现了一个异常:
回溯(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\ pyimod03_importers.py”,第 627 行,在 exec_module 文件中“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”中,第 20 行,在 swig_import_helper ImportError 中:DLL加载失败:找不到指定的模块。
在处理上述异常的过程中,又出现了一个异常:
回溯(最后一次调用):文件“hands_up_bending_counter_object_orient.py”,第 12 行,文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,在 exec_module 文件“tf_pose__init__.py”第 5 行中,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”中,第 627 行,在 exec_module 文件“tf_pose\ runner.py”,第 7 行,文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,exec_module 文件“tf_pose\common.py” ,第 3 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”中,第 627 行,在 exec_module 文件中site-packages\tensorflow__init__.py”,第 24 行,文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,exec_module 文件“site- packages\tensorflow\python__init__.py”,第 49 行,文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,exec_module 文件“site- packages\tensorflow\python\pywrap_tensorflow.py”,第 74 行,在 ImportError:Traceback(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper 文件“imp.py ",第 297 行,在 find_module ImportError 中:没有名为 '_pywrap_tensorflow_internal' 的模块\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,在 exec_module 文件“site-packages\tensorflow\python__init__.py”,第 49 行,在文件“c: \dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",第 627 行,在 exec_module 文件中 "site-packages\tensorflow\python\pywrap_tensorflow.py",第 74 行,在 ImportError 中:回溯(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper 文件“imp.py”,第 297 行,在 find_module ImportError:没有名为 '_pywrap_tensorflow_internal' 的模块\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,在 exec_module 文件“site-packages\tensorflow\python__init__.py”,第 49 行,在文件“c: \dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",第 627 行,在 exec_module 文件中 "site-packages\tensorflow\python\pywrap_tensorflow.py",第 74 行,在 ImportError 中:回溯(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper 文件“imp.py”,第 297 行,在 find_module ImportError:没有名为 '_pywrap_tensorflow_internal' 的模块第 49 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”中,第 627 行,在 exec_module 文件中“site-packages\tensorflow\python\pywrap_tensorflow.py ”,第 74 行,在 ImportError: Traceback (最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper 文件“imp.py”,第 297 行,在 find_module ImportError 中:没有名为“_pywrap_tensorflow_internal”的模块第 49 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”中,第 627 行,在 exec_module 文件中“site-packages\tensorflow\python\pywrap_tensorflow.py ",第 74 行,ImportError: Traceback (last recent call last):文件 "site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 18 行,在 swig_import_helper 文件 "imp.py",第 297 行,在 find_module ImportError 中:没有名为“_pywrap_tensorflow_internal”的模块site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 18 行,在 swig_import_helper 文件中 "imp.py",第 297 行,在 find_module ImportError: No module named '_pywrap_tensorflow_internal'site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 18 行,在 swig_import_helper 文件中 "imp.py",第 297 行,在 find_module ImportError: No module named '_pywrap_tensorflow_internal'
在处理上述异常的过程中,又出现了一个异常:
回溯(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\ pyimod03_importers.py”,第 627 行,在 exec_module 文件中“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”中,第 20 行,在 swig_import_helper ImportError 中:DLL加载失败:找不到指定的模块。
无法加载原生 TensorFlow 运行时。
见https://www.tensorflow.org/install/errors
出于一些常见的原因和解决方案。寻求帮助时,请在此错误消息上方包含整个堆栈跟踪。[32124] 未能执行脚本 hands_up_bending_counter_object_orient
我已尝试按照( https://github.com/pyinstaller/pyinstaller/issues/3754 )的建议将文件 _pywrap_tensorflow_internal.pyd 放入/tensorflow/python
dist 文件夹中的子目录(通过修改文件) ,但现在错误是:.spec
回溯(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\ pyimod03_importers.py”,第 627 行,在 exec_module 文件中“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件中“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,行24、在 swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 文件“imp.py”,第 243 行,在 load_module 文件“imp.py”,第 343 行,在 load_dynamic ImportError: DLL load failed:指定的模块无法找到。
在处理上述异常的过程中,又出现了一个异常:
回溯(最后一次调用):文件“postural_analysis_fast.py”,第 11 行,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”中,第 627 行,在 exec_module 文件“site-packages\tensorflow__init__.py”第 24 行中,在文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”中,第 627 行,在 exec_module文件“site-packages\tensorflow\python__init__.py”,第 49 行,文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,在 exec_module文件“site-packages\tensorflow\python\pywrap_tensorflow.py”,第 74 行,在 ImportError:Traceback(最近一次调用最后):文件“site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,文件“c:\dev\anaconda\envs\terminal\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”,第 627 行,exec_module 文件“site-packages\tensorflow\python\ pywrap_tensorflow_internal.py”,第 28 行,文件“site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 24 行,swig_import_helper 文件“imp.py”,第 243 行,load_module 文件“imp.py”,第 343 行,在 load_dynamic ImportError: DLL load failed: 找不到指定的模块。site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 24 行,在 swig_import_helper 文件中“imp.py”,第 243 行,在 load_module 文件中“imp.py”,第 343 行,在 load_dynamic ImportError:DLL 加载失败:指定找不到模块。site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 24 行,在 swig_import_helper 文件中“imp.py”,第 243 行,在 load_module 文件中“imp.py”,第 343 行,在 load_dynamic ImportError:DLL 加载失败:指定找不到模块。
无法加载原生 TensorFlow 运行时。
见https://www.tensorflow.org/install/errors
出于一些常见的原因和解决方案。寻求帮助时,请在此错误消息上方包含整个堆栈跟踪。[47340] 无法执行脚本 postural_analysis_fast</p>
编辑(24.04.2019):
我曾尝试使用 Dependencies 工具分析 _pywrap_tensorflow_internal.pyd,结果如下:Dependencies result。
我在Dependencies的文档中找不到红色问号是什么意思(可能缺少 dll?),但所有这些 dll 都已经存在于我的dist文件夹中(在主文件夹内)。
解决方案
我面临同样的问题并将依赖项工具应用于_pywrap_tensorflow_internal(tensorflow-gpu 1.12)。它需要一些 C:\WINDOWS\system32 文件,其中之一是 nvcuda.dll。此 cuda 文件在其他计算机中往往会丢失。希望这可以帮助。
1) https://groups.google.com/a/tensorflow.org/forum/#!topic/discuss/-BluoQjTSLM
推荐阅读
- javascript - 如何在猫鼬模式中定义具有一系列数据的字段?
- typescript - 如何使用 API v3 在 typescript 中设置谷歌驱动器文件权限?
- javascript - 如何感知可靠的移动设备角度?
- python - 数据框 concat 中的计划形状问题
- android - 获取对子节点 firebase 的引用
- matlab - Matlab是英文版,但是当绘图时我得到了中文
- c# - Parse csv to decimal on different cultures using CsvHelper in c#
- javascript - 在 html 的数据标题中添加#id
- c++ - 是否可以在不手动将重写的克隆方法添加到 C++ 中的每个派生类的情况下克隆多态对象?
- java - 无法将 Spring Boot RestController 响应转换为 JSON:`No converter found for return value of type: class ...`