tensorflow: ModuleNotFoundError: No module named 'tensorflow.examples.tutorials'
Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template
System information
- OS Platform and Distribution (macOS Mojave 10.14.6):
- TensorFlow installed from (source):
- TensorFlow version: 2.0.0-rc1
- Python version: Python 3.7.4
- Installed using virtualenv? pip? conda?: pip
Describe the problem
I am trying to run a basic mnist classifier tutorial using tensorflow (without keras) and I am getting the following error:
Upon running:
from tensorflow.examples.tutorials.mnist import input_data
I get the following error:
ModuleNotFoundError: No module named ‘tensorflow.examples.tutorials’
Any help of how to fix this issue is highly appreciated.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25
I had the same problem with TF2. In the tutorial that I had the following codes:
In in tf2, it turns out that I don’t need that turorial package, just write:
mnist = tf.keras.datasets.mnistI don’t get it, I buy a book called Deep Learning for Games, and know half of all the codes within the book doesn’t with tensorflow 2.0, what is the use if you want to learn deep programming??? Idiots need to up their brains.
This breaks a bunch of community code and tutorials. Could the issue be reopened and fixed as part of the tensorflow or datasets packages? A straight install of conda install tensorflow and conda install tensorflow-datasets didn’t solve the issue.
Why not conda/pip install tensorflow-examples? Copying lost files manually doesn’t seem like a good approach. Examples should probably state that they use older version code.
I ended up using tfds:
I found a solution at this link: https://blog.csdn.net/weixin_41663570/article/details/102512468
You just need to download the lost files and copy them to the tensorflow-core/ examples.
I’m also having exactly the same problem with Tensorflow 2.0.0 I changed the TensorFlow version to 1.14.0 and I was able to import tensorflow.examples.tutorials.mnist
I don’t know why this is happening. There seems to be no change in the examples package code.
but because of this it doesnot act like a dataset. Now it act like a module
I think the Tensorflow 2.0.0 can’t support to import tensorflow.examples.tutorials. Beacause I found the packages of tensorflow-core/examples had no the module named by turorials under my environment of anaconda installation. Finally, I changed the Tensorflow version to 1.14.0 and it did work! I’m very confused.
I didn’t (and I don’t think it matters)
I downloaded the example/tutorials folder on github tensorflow, and then imported the input.py module by the following method:
import syssys.path.append("D:/anaconda3/envs/tensorflow2/Lib/site-packages/tensorflow_core/examples/tutorials/mnist/")# I download ‘examples’ file by myself in github tensorflow projectimport input_dataFor deprecated API, The tf1 API be used under the tf2 env, by:
import tensorflow.compat.v1 as tftf.disable_v2_behavior()For this perticular problem of not getting ModuleNotFoundError: No module named 'tensorflow.examples.tutorials, i followed the following way to solve this issue… and it solved in my case. URL for Solution: https://www.youtube.com/watch?v=CH8uW3abI9A&feature=youtu.be
For this perticular problem of not getting ModuleNotFoundError: No module named 'tensorflow.examples.tutorials, i followed the following way to solve this issue… and it solved in my case. URL for Solution: https://www.youtube.com/watch?v=CH8uW3abI9A&feature=youtu.be
TF2 does not support from
tensorflow.examples.tutorials.mnist import input_dataInstead using older version of Tensorflow just go ahead withpip install tensorflow-datasetsorconda install tensorflow-datasetsUse the data set by following codeimport tensorflow_datasets as datasetsmnist = datasets.load(name='mnist')