python-3.x - 在 Windows 中导入 tensorflow 模块时遇到问题
问题描述
导入 tensorflow Traceback(最近一次调用最后):文件“D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 18 行,在 swig_import_helper fp,路径名,描述 = imp.find_module('_pywrap_tensorflow_internal' , [dirname( file )]) File "D:\python36\lib\imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named '_pywrap_tensorflow_internal'
在处理上述异常的过程中,又出现了一个异常:
Traceback(最近一次调用最后):文件“D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,从 tensorflow.python.pywrap_tensorflow_internal 导入 * 文件“D:\python36\lib \site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 20 行,在 swig_import_helper导入_pywrap_tensorflow_internal ModuleNotFoundError:没有名为“_pywrap_tensorflow_internal”的模块
在处理上述异常的过程中,又出现了一个异常:
回溯(最近一次调用最后):文件“”,第 1 行,在文件“D:\python36\lib\site-packages\tensorflow__init__.py”中,第 24 行,在 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused -import 文件“D:\python36\lib\site-packages\tensorflow\python__init__.py”,第 49 行,从 tensorflow.python 导入 pywrap_tensorflow 文件“D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow .py",第 74 行,在 raise ImportError(msg) ImportError: Traceback (last recent call last): File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 18 行,在 swig_import_helper fp,路径名,描述 = imp.find_module('_pywrap_tensorflow_internal', [dirname(文件)]) 文件“D:\python36\lib\imp.py”,第 296 行,在 find_module 中引发 ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named '_pywrap_tensorflow_internal'
在处理上述异常的过程中,又出现了一个异常:
Traceback(最近一次调用最后):文件“D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,从 tensorflow.python.pywrap_tensorflow_internal 导入 * 文件“D:\python36\lib \site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 20 行,在 swig_import_helper导入_pywrap_tensorflow_internal ModuleNotFoundError:没有名为“_pywrap_tensorflow_internal”的模块
无法加载原生 TensorFlow 运行时。
见https://www.tensorflow.org/install/errors
出于一些常见的原因和解决方案。寻求帮助时,请在此错误消息上方包含整个堆栈跟踪。
解决方案
1. 使用蟒蛇
Anaconda使用类似于 PyPI 的 conda 分布索引。TensorFlow conda 构建使用MKL(英特尔数学内核库)。它可以在没有 AVX 的情况下工作。
下载此处提到的 Anaconda并创建此处提到的新 conda 环境。
运行此命令:
conda install tensorflow
2. 使用来自tensorflow-windows-wheel 仓库的构建。
这个 repo 包含许多使用 SSE 而不是 AVX 构建的 TensorFlow pip wheel 文件。SSE 构建运行时没有任何编译错误。使用来自 repo 的这个文件。
希望这可以帮助。
推荐阅读
- bash - Mac .bashrc 中的源/别名不是永久的
- javascript - 未捕获的错误:[$injector:modulerr] 尝试加载 pdf 打印页面
- asp.net - ExpressiveAnnotations requiredIf Validation Firing when Tabbing to Field
- python - Curve_fit 产生一条平线
- c# - RDLC 内存泄漏
- node.js - 应用程序启动时,NodeJS Windows 10 地理定位模块在电子中引发错误
- powershell-ise - 防止 PowerShell ISE 在编辑期间取消折叠函数
- azure-cosmosdb - Cosmos DB 未检索分区键的数据
- scala.js - 升级后 app-fastopt.js 不再正确添加到资源中
- kotlin - gRPC over TLS 使用 Netty/Kortlin/Ktor 引发错误并阻止 gNMI 工作