简体   繁体   中英

While importing tensorflow, got the error 'ImportError: DLL load failed: The specified module could not be found.'

I have seen and implemented several potential solutions to my problem, but none seem to work. Can I get resolution for the error in importing tensorflow?

Versions -- > 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.

Anaconda offers an installation for Tensorflow that takes care of everything, including all the GPU and CUDA dependencies:

conda install -c anaconda tensorflow-gpu

It's for Tensorflow 2.1 and Python 3.7. DLL failures are common when components are installed separately or through another channel than Anaconda.

I think the package didn't installed correctly. try reinstalling it.(if you use 'pip' to install don't forget to update it)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM