tensorflow import error: DLL load failed: The specified module could not be found (DLL load failed: The specified module could not be found)

The background,
Recently, after my tensorFlow version was updated, there was a problem, and the error was also very vague: DLL Load failed: the specified module could not be found. Here is my environment first:

win10 + pycharm
Anaconda3 (python3.6)
tensorflow1.9

Ii. Problem description
My own version of TensorFlow, 1.9, has been in use for almost a year and has been fine. Later, I saw that the version of TensorFlow was updated to 1.12, so I thought I would update it. However, after the update, the error of importing tensorFlow was reported. Later, even if the tensorFlow version was reduced to 1.2, the error was still reported:


When importing TensorFlow, an error message will be sent:

D:\python\anaconda\python.exe D:*****.py
Traceback (most recent call last):
  File "D:\python\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\python\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\python\anaconda\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 "D:\python\anaconda\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\python\anaconda\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module cannot be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/python/item/64-MARTAGAN/train_marta_gan.py", line 7, in <module>
    import tensorflow as tf
  File "D:\python\anaconda\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\python\anaconda\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "D:\python\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\python\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "D:\python\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "D:\python\anaconda\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 "D:\python\anaconda\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "D:\python\anaconda\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module cannot be found.


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.

Process finished with exit code 1

My error message is in Chinese: DLL Load failed: the specified module cannot be found; Specified Module Could not be Found DLL Load Failed: The Specified Module could not be found
3. Solutions
The problem is new, the current solution is less online, after a search, finally found a similar problem and I post on making the first link: https://github.com/tensorflow/tensorflow/issues/25597, are described in detail below.
The situation of paster is similar to mine. The environment of paster is given first:

You can see that the sponsor also updated the TensorFlow version to 1.12 before encountering this problem. The following is a detailed description of how to configure your environment, and mentions that this error still occurs with CUDA9.2 and CUDA10.0 versions.
To address this problem, it has been proposed to install CUDA9.0:

The user then reconfigured his environment to CUDA9.0 and cuDNN7.05

About how to view your CUDA version, you can open CMD and type NVCC — Version in CMD to view:

Here are some of the approaches I tried, but none of them solved the problem:
(1) Install other versions of CUDA. But it didn’t solve the problem…
(2) Update VS2015, reference blog: TensorFlow installation issues and Github. But it doesn’t solve the problem…

(3) Continue to read the post on Github, found that many people are thanking the layer owner FO40255, which is the above (2) layer owner message, reinstall the.WHL file, but I did not try this method, I will mention my method later, here is a random post:

To sum up my own approach to this problem:
(1) Open CMD and enter PIP Uninstall tensorFlow, that is, uninstall TensorFlow.
(2) Re-install after uninstalling and enter PIP Install TensorFlow.
(3) After the installation of a simple test, there is no error. In short, if it breaks, reinstall it… (That’s how I got it back.)

Of course, if reinstall will not solve the problem, can consider fo40255 layer above the main method, cover again. WHL file, the file link here also is given, by the way: https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/sse2

Read More: