Python 3.x 运行示例代码时出错:未能加载本机TensorFlow运行时

Python 3.x 运行示例代码时出错:未能加载本机TensorFlow运行时,python-3.x,Python 3.x,当我尝试运行一个基本的加法代码时,我得到以下错误 我用下面的线来安装tensorflow C:\Users\bjnag> pip install tensorflow --upgrade --force-reinstall 我使用的是Windows10,Python 3.5.6 | Anaconda,Inc Traceback (most recent call last): File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\s

当我尝试运行一个基本的加法代码时,我得到以下错误

我用下面的线来安装tensorflow

C:\Users\bjnag> pip install tensorflow --upgrade --force-reinstall
我使用的是Windows10,Python 3.5.6 | Anaconda,Inc

  Traceback (most recent call last):
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/bjnag/Desktop/Machine Learning/Linked in/tensorflow/Exercise Files/02/addition final.py", line 2, in <module>
    import tensorflow as tf
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
回溯(最近一次呼叫最后一次):
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow.py”,第58行,在
从tensorflow.python.pywrap\u tensorflow\u内部导入*
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow\u internal.py”,第28行,在
_pywrap\u tensorflow\u internal=swig\u import\u helper()
swig\u import\u helper中的文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow\u internal.py”第24行
_mod=imp.load_模块(“pywrap_tensorflow_internal”,fp,路径名,描述)
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py”,第243行,在加载模块中
返回加载动态(名称、文件名、文件)
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py”,第343行,在load\u dynamic中
返回负载(规格)
ImportError:DLL加载失败:找不到指定的模块。
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:/Users/bjnag/Desktop/Machine Learning/Linked in/tensorflow/Exercise Files/02/addition final.py”,第2行,在
导入tensorflow作为tf
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\\uuuuu init\uuuu.py”,第101行,在
从tensorflow_核心导入*
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\uuuuu init\uuuuu.py”,第40行,在
从tensorflow.python.tools将模块_util作为_模块_util导入
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\ \uuuu init\uuuu.py”,第50行,在uu getattr中__
模块=自身。_加载()
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\ \uuuuu init\uuuu.py”,第44行,加载
模块=_importlib.import_模块(自身名称)
导入模块中的文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\importlib\\ uuuuuuu init\uuuuuu.py”,第126行
return _bootstrap._gcd_import(名称[级别:],包,级别)
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\\uuuu init\uuuu.py”,第49行,在
从tensorflow.python导入pywrap\u tensorflow
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow.py”,第74行,在
提高效率(msg)
ImportError:回溯(最近一次呼叫上次):
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow.py”,第58行,在
从tensorflow.python.pywrap\u tensorflow\u内部导入*
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow\u internal.py”,第28行,在
_pywrap\u tensorflow\u internal=swig\u import\u helper()
swig\u import\u helper中的文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\u core\python\pywrap\u tensorflow\u internal.py”第24行
_mod=imp.load_模块(“pywrap_tensorflow_internal”,fp,路径名,描述)
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py”,第243行,在加载模块中
返回加载动态(名称、文件名、文件)
文件“C:\Users\bjnag\Anaconda3\envs\tensorflow\lib\imp.py”,第343行,在load\u dynamic中
返回负载(规格)
ImportError:DLL加载失败:找不到指定的模块。
未能加载本机TensorFlow运行时

因为一些常见的原因和解决方案。包括整个堆栈跟踪 以上是请求帮助时的错误消息


有人能帮我吗。

我在尝试运行tf==v2.1时,在Windows 10上遇到了相同的错误。在仔细检查了所有的系统版本要求和读取页面之后,我真正解决的是更新VisualC++的可重新分配。