无法加载本机Tensorflow运行时

时间:2020-01-21 19:24:59

标签: python tensorflow keras

我一直在使用tensorflow(通过Keras)来完成一些简单的图像分类任务。去年下半年(12月中旬)运行良好,但现在我做了一些软件包更新,尝试运行我的代码时出现此错误:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python\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:\Python\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Python\lib\imp.py", line 342, 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 "image_classify.py", line 3, in <module>
    from keras.preprocessing.image import array_to_img, img_to_array, load_img
  File "C:\Python\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import utils
  File "C:\Python\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
    from . import conv_utils
  File "C:\Python\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "C:\Python\lib\site-packages\keras\backend\__init__.py", line 1, in <module>
    from .load_backend import epsilon
  File "C:\Python\lib\site-packages\keras\backend\load_backend.py", line 90, in <module>
    from .tensorflow_backend import *
  File "C:\Python\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "C:\Python\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Python\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Python\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Python\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Python\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python\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:\Python\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Python\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

自然而然的是某些软件包更新破坏了某些内容,但我不确定它可能是哪一个。我拥有tensorflow(2.1.0)和Keras(2.3.1)的(当前)最新版本。我正在使用具有Intel i5-7200U cpu的Windows 10 PC。我没有使用tensorflow-gpu,因为我在没有专用gpu的笔记本电脑上运行此小任务,如果有帮助的话。

有人可以帮助我找出发生了什么变化吗?谢谢!

1 个答案:

答案 0 :(得分:0)

此问题的常见解决方案是您需要从here安装/更新Microsoft Visual C ++ 2015-2019可再发行组件(x64)

有关更多详细信息,请参阅回答here的类似问题。