tensorflow: ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
import tensorflow as tf
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 64-bit
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow installed from (source or binary): pip package manager
- TensorFlow version (use command below): 1.12.0
- Python version: Python 3.6.7 64-bit
- Bazel version (if compiling from source):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version: No GPU
- GPU model and memory: No GPU
You can collect some of this information using our environment capture script You can also obtain the TensorFlow version with python -c “import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)”
Describe the current behavior Just to test after installation, I tried importing Tensorflow in Python, but got an unexpected error (see Code section) .
Describe the expected behavior I think it will just keep going like this unless I fix the problem…
Code to reproduce the issue
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\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 "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import tensorflow as tf
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\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 "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\UNO\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine 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.
>>>
Other info / logs
Yeah… Maybe no logs here. I’ve got a little Not included in PATH
log when installing, though.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 46 (4 by maintainers)
People, I have solved my problem taking another path. I uninstalled the TensorFlow package that I installed using pip and reinstall using “conda install TensorFlow” and it worked! Now I can import TensorFlow without problems. Hope this can help you guys too!
Closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!
@duncanhalstead Do the following.
Run the anaconda prompt as administrator.(right click-> run as administrator).
pip uninstall tensorflow.
Close anaconda prompt.
Again run anaconda prompt as administrator.
type: conda install tensorflow It will ask for some y / n Type y.
Now after all done, change your python interpreter’s environment to anaconda environment where you installed tensorflow.
Now try importing tensorflow.
hope this helps 😃
@TamirisCrepalde you just saved the day! Thank you very much!!
https://github.com/tensorflow/tensorflow/issues/23686
pip install protobuf==3.5.1