【问题标题】:Failed to load the native TensorFlow runtime: error while importing tensorflow未能加载原生 TensorFlow 运行时:导入 tensorflow 时出错
【发布时间】:2021-02-23 14:13:29
【问题描述】:

我安装了tensorflow 1.12.0.while impoting tensorflow in python3.9.1..faced error below

ImportError Traceback(最近调用 最后的) c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py 在 swig_import_helper() 17 尝试: ---> 18 fp,路径名,描述 = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)]) 19 除了 ImportError:

c:\users\renis\appdata\local\programs\python\python39\lib\imp.py 在 查找模块(名称,路径) 295 其他: --> 296 引发 ImportError(_ERR_MSG.format(name), name=name) 297

ImportError:没有名为“_pywrap_tensorflow_internal”的模块

在处理上述异常的过程中,又发生了一个异常:

ModuleNotFoundError Traceback(最近调用 最后的) c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow.py 在 57 ---> 58 来自 tensorflow.python.pywrap_tensorflow_internal 导入 * 59 从 tensorflow.python.pywrap_tensorflow_internal 导入 版本

c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py 在 27 返回 _mod ---> 28 _pywrap_tensorflow_internal = swig_import_helper() 29 del swig_import_helper

c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py 在 swig_import_helper() 19 除了 ImportError: ---> 20 导入_pywrap_tensorflow_internal 21 返回_pywrap_tensorflow_internal

ModuleNotFoundError:没有名为“_pywrap_tensorflow_internal”的模块

在处理上述异常的过程中,又发生了一个异常:

ImportError Traceback(最近调用 最后)在 ----> 1 导入张量流

c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow_init_.py 在 22 23 # pylint: 禁用=g-bad-import-order ---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import 25 26 次尝试:

c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python_init_.py 在 47 将 numpy 导入为 np 48 ---> 49 从 tensorflow.python 导入 pywrap_tensorflow 50 51 from tensorflow.python.tools import component_api_helper

c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow.py 在 72 一些常见的原因和解决方案。包括整个堆栈跟踪 73 上面这个错误信息请求帮助时。""" % traceback.format_exc() ---> 74 引发 ImportError(msg) 75 76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback(最近一次调用最后一次):文件 "c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", 第 18 行,在 swig_import_helper 中 fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
文件 "c:\users\renis\appdata\local\programs\python\python39\lib\imp.py", 第 296 行,在 find_module 中 raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named '_pywrap_tensorflow_internal'

在处理上述异常的过程中,又发生了一个异常:

Traceback(最近一次调用最后一次):文件 "c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", 第 58 行,在 从 tensorflow.python.pywrap_tensorflow_internal 导入 * 文件“c:\users\renis\appdata\local\programs\python\python39\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, 第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“c:\users\renis\appdata\local\programs\python\python39\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

出于一些常见原因和解决方案。包括整个堆栈跟踪 寻求帮助时出现此错误消息。

​请帮忙解决这个问题。

【问题讨论】:

标签: python tensorflow-datasets


【解决方案1】:

Python 3.9 需要 Tensorflow 2.5 或更高版本。需要按照python升级Tensorflow版本。

您可以使用以下代码来升级 tensorflow:

pip install --upgrade pip
pip install --upgrade tensorflow 

关注此link 以检查和安装兼容的 Tensorflow 版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 2021-01-07
    • 2017-10-19
    • 1970-01-01
    • 2020-04-28
    • 2017-11-21
    • 1970-01-01
    相关资源
    最近更新 更多