无法使用keras - ImportError:没有名为'_pywrap_tensorflow_internal'的模块

时间:2018-04-18 05:52:41

标签: python python-3.x tensorflow keras anaconda

我正在尝试执行命令
python -c "from keras import backend"
但在执行时我收到以下错误。


    (aind-cv) C:\Users\Harikesh>python -c "from keras import backend"
    Using TensorFlow backend.
    Traceback (most recent call last):
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
        return importlib.import_module(mname)
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 985, in _gcd_import
      File "", line 968, in _find_and_load
      File "", line 957, in _find_and_load_unlocked
      File "", line 666, in _load_unlocked
      File "", line 577, in module_from_spec
      File "", line 938, in create_module
      File "", line 222, in _call_with_frames_removed
    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\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in 
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in 
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named '_pywrap_tensorflow_internal'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "", line 1, in 
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\__init__.py", line 3, in 
        from . import utils
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\utils\__init__.py", line 6, in 
        from . import conv_utils
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\utils\conv_utils.py", line 9, in 
        from .. import backend as K
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\backend\__init__.py", line 84, in 
        from .tensorflow_backend import *
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in 
        import tensorflow as tf
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\__init__.py", line 24, in 
        from tensorflow.python import *
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\__init__.py", line 51, in 
        from tensorflow.python import pywrap_tensorflow
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in 
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
        return importlib.import_module(mname)
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 985, in _gcd_import
      File "", line 968, in _find_and_load
      File "", line 957, in _find_and_load_unlocked
      File "", line 666, in _load_unlocked
      File "", line 577, in module_from_spec
      File "", line 938, in create_module
      File "", line 222, in _call_with_frames_removed
    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\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in 
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in 
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named '_pywrap_tensorflow_internal'


    Failed to load the native TensorFlow runtime.

    See https://www.tensorflow.org/install/install_sources#common_installation_problems

    for some common reasons and solutions.  Include the entire stack trace
    above this error message when asking for help.

我正在使用Anaconda并提到该网站来解决问题,但它没有解决。我正在尝试执行this中提供的任务。我的张量流代码工作正常,但我不能仅使用keras。

1 个答案:

答案 0 :(得分:0)

由于我无法发表评论,我将此作为答案。 确保你有lib MSVCP140.DLL。您可以签入system->路径变量。如果没有,您可以从这里下载link。还要确保为系统下载正确的32/64位。

也可能是this

的副本