ModuleNotFoundError: No module named ‘tensorflow.python’ And the pits encountered after installation

ModuleNotFoundError: No module named 'tensorflow.python'

after we installed tensorflow, we thought we had debuggable the environment and PIP install tensorflow, if

is entered in CMD

import tensorflow

(normally installed the GPU version tensorflow) :

but may be submitted to the above error, on the Internet a lot according to the results there is no use, 😂 is outrageous.
reason (personal summary) : the computer installed multiple python environment, not only the environment, but also anconda, etc., constitute the virtual environment, so you will encounter various problems when using the command conda to assemble the tensflow environment.
the solution: delete other environment, if you remove after the computer did not have the python environment, then reinstall it again, because I have more than one person has them around, “reshipment can solve the problem of ninety-nine percent”, but if pycharm with few words, I do not recommend to assemble anconda, unloading directly, in python’s official website to download the new version of python. After that, tensorFlow is assembled in the whole large Python environment; With the PIP command, there is little problem with reloading.

after installed, we can run the minist a piece of code: </ p>

from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets("E:\\桌面\\datatest")
# 打印训练数据大小
print("Training data size:", mnist.train.num_examples)
# 打印验证集大小
print("Validating data size:", mnist.validation.num_examples)
# 打印测试集大小
print("Testing data size:", mnist.test.num_examples)
# 打印训练样例
print("Example training data", mnist.train.images[0])
# 打印训练样例的标签
print("Example training data label:", mnist.train.labels[0])


, ninety-nine percent of the time will error and remind:

ModuleNotFoundError: No module named 'tensorflow.tutorials'

We first enter the installation environment of tensorflow, and we can find the installation path

through python’s path method

import tensorflow as tf

after entering python environment, type the command and get the path, and then find the path of files
(about) the new version of the tensflow

enter the examples of the first file,
there should be no my red line mark.
go here to download, then copy in the directory, if it is the old version, find the examples file, the effect is the same, after found on the Internet part of the introduction code may also have problems. Note that we must refer to pylab with

from matplotlib import pylab

so, when you’re done, you can run the following code.

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
print ( ' 输入数据:', mnist.train.images)
print ( ' 输入数据打shape :', mnist.train.images.shape)
from matplotlib import pylab
im = mnist.train.images[1]
im = im.reshape(-1 ,28)
  • note that our read_data_sets should never be interrupted when downloading data. If they are interrupted, they will report an error if they continue executing later. At this time, either change the path to download again, or find the original download path, delete it and run again.

Read More: