导入tensorflow时出现错误“导入错误:DLL加载失败:找不到指定的模块。”

时间:2020-08-06 08:20:20

标签: python tensorflow import compiler-errors

我已经看到并实施了一些解决我的问题的潜在解决方案,但似乎没有一个可行。 我可以为导入tensorflow的错误获得解决方案吗?

版本 -> python 3.7.4 ->张量流2.3.0

runfile('C:/Users/pshad/.spyder-py3/temp.py', wdir='C:/Users/pshad/.spyder-py3') Traceback (most recent call last):

  File "<ipython-input-27-bc8fb4f78acd>", line 1, in <module>
    runfile('C:/Users/pshad/.spyder-py3/temp.py', wdir='C:/Users/pshad/.spyder-py3')

  File "C:\Users\pshad\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\pshad\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/pshad/.spyder-py3/temp.py", line 9, in <module>
    import tensorflow as tf

  File "C:\Users\pshad\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util

  File "C:\Users\pshad\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
    from tensorflow.python.eager import context

  File "C:\Users\pshad\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
    from tensorflow.python import pywrap_tfe

  File "C:\Users\pshad\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow

  File "C:\Users\pshad\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)

ImportError: Traceback (most recent call last):   File "C:\Users\pshad\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed: The specified module could not be found.


Failed to load the native TensorFlow runtime.

2 个答案:

答案 0 :(得分:1)

Anaconda为Tensorflow提供了一个安装程序,可以处理所有事情,包括所有GPU和CUDA依赖项:

conda install -c anaconda tensorflow-gpu

适用于Tensorflow 2.1和Python 3.7。当单独安装组件或通过Anaconda以外的其他渠道安装组件时,DLL故障很常见。

答案 1 :(得分:0)

我认为该软件包未正确安装。尝试重新安装。(如果您使用“ pip”进行安装,请不要忘记对其进行更新)