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

2024-05-23 20:54:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经看到并实施了一些解决我的问题的潜在方案,但似乎都不起作用。 我可以解决导入tensorflow时的错误吗

版本 -->;python 3.7.4 -->;tensorflow 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.

Tags: inpyimportlibpackagestensorflowlinesite
2条回答

我认为软件包安装不正确。尝试重新安装。(如果使用“pip”安装,请不要忘记更新它)

Anaconda为Tensorflow提供了一个安装,它负责所有事情,包括所有GPU和CUDA依赖项:

conda install -c anaconda tensorflow-gpu

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

相关问题 更多 >