前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >[754]ImportError: DLL load failed: 找不到指定的模块

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

作者头像
周小董
发布2020-02-14 18:04:08
发布2020-02-14 18:04:08
14.7K00
代码可运行
举报
文章被收录于专栏:python前行者python前行者
运行总次数:0
代码可运行

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

代码语言:javascript
代码运行次数:0
运行
复制
>>> 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文件。具体如下图:

附上找到解决方法的原帖:https://stackoverflow.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

代码语言:javascript
代码运行次数:0
运行
复制
pip install tensorflow-cpu
pip install tensorflow-gpu

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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/01/27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档