0
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data as input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

I have just started to work with tensorflow and when I try to import the mnist dataset, I get the following error.

Traceback (most recent call last):
  File "tensorflow.py", line 1, in <module>
    import tensorflow as tf
  File "/home/shivam/study/deep learning/tensorflow.py", line 2, in <module>
    import tensorflow.examples.tutorials.mnist.input_data as input_data
ImportError: No module named examples.tutorials.mnist.input_data

I have checked the python path and confirmed that the mnist dataset exists in one of the python paths(/usr/local/lib/python2.7/dist-packages).

['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

I even tried this method as suggested here but again I get a import error.

Traceback (most recent call last):
  File "tensorflow.py", line 1, in <module>
    import tensorflow as tf
  File "/home/shivam/study/deep learning/tensorflow.py", line 2, in <module>
    import input_data
  File "/home/shivam/study/deep learning/input_data.py", line 29, in <module>
    from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets
ImportError: No module named contrib.learn.python.learn.datasets.mnist
Community
  • 1
  • 1
Shivam Mitra
  • 1,040
  • 3
  • 17
  • 33

1 Answers1

3

Don't call your file tensorflow.py, call it something else. For instance my_experiment1.py. That should fix it!

avloss
  • 2,389
  • 2
  • 22
  • 26