安装tf2失败:ImportError: DLL load failed: 找不到指定的模块。

来源:1-6 Tensorflow环境配置

慕瓜4330502

2020-06-06

import tensorflow as tf

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     57 
---> 58   from tensorflow.python.pywrap_tensorflow_internal import *
     59 

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>
     27             return _mod
---> 28     _pywrap_tensorflow_internal = swig_import_helper()
     29     del swig_import_helper

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
     23             try:
---> 24                 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
     25             finally:

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\imp.py in load_module(name, file, filename, details)
    242         else:
--> 243             return load_dynamic(name, filename, file)
    244     elif type_ == PKG_DIRECTORY:

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\imp.py in load_dynamic(name, path, file)
    342             name=name, loader=loader, origin=path)
--> 343         return _load(spec)
    344 

ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-2-64156d691fe5> in <module>
----> 1 import tensorflow as tf

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\__init__.py in <module>
     39 import sys as _sys
     40 
---> 41 from tensorflow.python.tools import module_util as _module_util
     42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     43 

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py in <module>
     48 import numpy as np
     49 
---> 50 from tensorflow.python import pywrap_tensorflow
     51 
     52 # Protocol buffers

E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     67 for some common reasons and solutions.  Include the entire stack trace
     68 above this error message when asking for help.""" % traceback.format_exc()
---> 69   raise ImportError(msg)
     70 
     71 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
  File "E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "E:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tensorflow\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.

我的环境:anaconda、python3.7、windows8、CPU笔记本

我一开始尝试直接安装pip install tensorflow,装的是tf2.2,便出现这个ImportError问题。我根据网上的攻略安装了cuda10.2、cudann,但是错误没有解决。

之后我开始尝试tensorflow2.0 cpu版本还是失败,最后我尝试用anacoda安装tensorflow2 + cuda9,但还是失败,出现的是同样的错误:ImportError。

请教老师我该怎么解决这个问题,还是我只能用tensorflow1.X?

写回答

1回答

正十七

2020-06-07

这个的原因很复杂,估计是版本匹配的问题,但具体是哪个环节出错,老师也无从判断。不建议在windows上配置GPU环境,装个能用的tensorflow学习用就可以了。建议去linux上配置GPU版本的tensorflow。

0
0

Google老师亲授 TensorFlow2.0 入门到进阶

Tensorflow2.0实战—以实战促理论的方式学习深度学习

1849 学习 · 896 问题

查看课程