[754]ImportError: DLL load failed: 找不到指定的模块

在tensorflow的学习中,想使用tensorflow-gpu版的学习,充分利用计算机。但是跟网上很多博主的方法安装gpu,cuda是安装成功了,但是却一直报以下一个错误。

>>> import tensorflow
Traceback (most recent call last):
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\soft\python3.6\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 "D:\soft\python3.6\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\soft\python3.6\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\soft\python3.6\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\__init__.py", line 42, in <module>
    from . _api.v2 import audio
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\_api\v2\audio\__init__.py", line 10, in <module>
    from tensorflow.python.ops.gen_audio_ops import decode_wav
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\ops\gen_audio_ops.py", line 9, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "D:\soft\python3.6\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "D:\soft\python3.6\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "D:\soft\python3.6\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\soft\python3.6\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\soft\python3.6\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 "D:\soft\python3.6\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\soft\python3.6\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: 找不到指定的模块。


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

在找了很多方法后,终于找到了原因所在,原来是win10中环境配置的原因,win10中,不仅要添加环境变量path的值,还需要在PATHEXT中添加.DLL否则系统就无法加载指定的模块,即使你的文件中有.dll文件。具体如下图:

[754]ImportError: DLL load failed: 找不到指定的模块

附上找到解决方法的原帖:https://*.com/questions/42011070/on-windows-running-import-tensorflow-generates-no-module-named-pywrap-tenso


我遇到这个问题是安装hanlp,安装hanlp的时候是自动安装的2.0.0a10这个版本的,而2.0.0a10这个版本requirement tensorflow==2.1.0rc2,但实际不用去对应,我就是版本对应了才报错的,最后安装的tensorflow==2.0.0,问题解决了

ERROR: hanlp 2.0.0a10 has requirement tensorflow==2.1.0rc2, but you’ll have tensorflow 2.0.0 which is incompatible.

tensorflow-gpu 需要和cuda,cudnn版本对应。cuda又需要和英伟达驱动对应。

cuda10支持 tf 1.13 以上
cuda9支持 tf 1.5-1.12
cuda8支持 tf 1.0-1.4

也可能是你用的tensorFlow 版本太新了,不支持老cpu,用3.5的

也可能需要安装tensorflow-cpuortensorflow-gpu

pip install tensorflow-cpu
pip install tensorflow-gpu

参考:https://www.jianshu.com/p/0b917a1a723b
http://www.imooc.com/qadetail/294613

[754]ImportError: DLL load failed: 找不到指定的模块[754]ImportError: DLL load failed: 找不到指定的模块 周小董 发布了553 篇原创文章 · 获赞 510 · 访问量 201万+ 他的留言板 关注
上一篇:pip更新超时失败之解法


下一篇:applied soft computing 投稿填坑1