Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I created a program to load a dataset from TensorFlow and I got an error that I have no idea what it means.

My code is:

import tensorflow as tf 
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt 

data = keras.dataset_fashion_mnist

(train_images, train_labels), (test_images, test_labels) = data.data_load()

print(train_labels[1])
I supposed to get a number as output and not an error.

The error is:

<pre>Traceback (most recent call last):
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\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\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, 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 "helloworld.py", line 1, in <module>
    import tensorflow as tf
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\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\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.


What I have tried:

I have no idea what to do to solve this and what to try. I made sure that I have tensorflow installed and I do. I think it has something to do with the library itself.
Posted
Comments
Visweswaran N 17-Nov-19 5:12am    
Do you have a 32-bit processor or something?

From this python path (C:\Users\Khosr\AppData\Local\Programs\Python\Python37) I could see you are running under windows and to me it seems like a 64 bit installation as of 32 the path would be something like Python37-32 although I am not sure on this.

Anyways I suggest you to go with Anaconda it comes with all necessary packages and IDE's for the data-science.

See here:

https://github.com/tensorflow/tensorflow/issues/23683#issuecomment-510718458
Khosraw 17-Nov-19 12:06pm    
I have a 64-bit proccessor so that may not be the problem. Something most likely has gone wrong with the installation of the packages.
Khosraw 17-Nov-19 19:22pm    
Using Anaconda did not help. I was hoping it did but it did not.

1 solution

Install the latest version of python i.e version 3
And still if it is not clear use Anaconda for secured installation of libraries
for detailed installation type this anaconda prompt:
1.
conda create -n tensorflow_cpu pip python=3.6

2.
activate tensorflow_cpu

3.
(tensorflow_cpu) C:\Users\sglvladi>

4.
pip install --ignore-installed --upgrade tensorflow==1.9

5.
python

6.import tensorflow as tf
7.hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
 
Share this answer
 
Comments
Khosraw 19-Nov-19 21:00pm    
Did not work for me but worked for others.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900