Cannot import TensorFlow

I want to learn TensorFlow to improve our AI skill I write TensorFlow tutorial to Google https://www.tutorialspoint.com/tensorflow/tensorflow_installation.htm and start to read from Tutorialspoint I did install python, pip, anaconda and tensorflow on a anaconda environment when I run python shell and try import tensorflow as it gives me error:

(tensorflow) C:\Users\user>python Python 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow Traceback (most recent call last): File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: Devingen bağlantı kitaplığını (DLL) başlatma işlemi başarısız.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init_.py”, line 98, in
from tensorflow_core import *
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core_init_.py”, line 40, in
from tensorflow.python.tools import module_util as module_util
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init
.py", line 50, in getattr
module = self.load()
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init
.py", line 44, in _load
module = importlib.import_module(self.name)
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\importlib_init
.py", line 127, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python_init
.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py”, line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py”, line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py”, line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py”, line 24, in swig_import_helper
_mod = imp.load_module(’_pywrap_tensorflow_internal’, fp, pathname, description)
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py”, line 242, in load_module
return load_dynamic(name, filename, file)
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py”, line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Devingen bağlantı kitaplığını (DLL) başlatma işlemi başarısız.

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.

how can I solve this problem?

My first thought is that I don’t believe TensorFlow is built for Python3.7+ yet. Try with 3.6 and see if that helps.

(tensorflow) C:\Users\user>python Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf Traceback (most recent call last): File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py", line 343, in load_dynamic return _load(spec) ImportError: DLL load failed: Devingen bağlantı kitaplığını (DLL) başlatma işlemi başarısız.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init_.py”, line 98, in
from tensorflow_core import *
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core_init_.py”, line 40, in
from tensorflow.python.tools import module_util as module_util
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init
.py", line 50, in getattr
module = self.load()
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_init
.py", line 44, in _load
module = importlib.import_module(self.name)
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\importlib_init
.py", line 126, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python_init
.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py”, line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py”, line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py”, line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py”, line 24, in swig_import_helper
_mod = imp.load_module(’_pywrap_tensorflow_internal’, fp, pathname, description)
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py”, line 243, in load_module
return load_dynamic(name, filename, file)
File “C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py”, line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Devingen bağlantı kitaplığını (DLL) başlatma işlemi başarısız.

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.

I only speak English, what does Devingen bağlantı kitaplığını (DLL) başlatma işlemi başarısız. mean?

DLL start process failed

Ahh, I understand the problem. Looking at the tutorial, you are installing tensorflow-gpu. This package requires many GPU and Deep Learning libraries, which clearly are either not installed or not installed properly.

The easiest solution is to uninstall tensorflow-gpu and install tensorflow, which will mean your models will train on your CPU ONLY.

If you want to train on your GPU if you have one, check out this guide. This is going to take many hours and attempts for most people, FYI. Especially for someone doing it for the first time.

its output the same error…

You’re saying that after running

pip uninstall tensorflow-gpu
and
pip install tensorflow

You get the same error after importing tensorflow?

Another solution I’ve seen is to instead run conda install tensorflow. The next alternative will be to install an older version, but that seems more like of a workaround than a solution.

I just delete previous and install on a brand new environment with

pip install tensorflow

only

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.