error
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
#加载数据集,参数为下载的路径,如果该路径下没有数据集的话,则会从网上自动下载。
#read_data_sets函数
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])
When
, 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
print(tf.__path__)
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.
portal
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.
1.
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)
pylab.imshow(im)
pylab.show()
- 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:
- ModuleNotFoundError: No module named ‘requests‘ [How to Solve]
- [Solved] ModuleNotFoundError: No module named ‘requests‘
- [Solved] ModuleNotFoundError: No module named ‘_polyiou‘
- [Solved] ByteTrack Error: ModuleNotFoundError: No module named ‘yolox’
- How to Solve PyInstaller Package Error: ModuleNotFoundError: No module named ‘xxxx‘
- [Solved] Pytest Error: E ModuleNotFoundError: No module named ‘common
- [Solved] Pychar error: modulenotfounderror: no module named ‘requests_ HTML ‘solution
- ModuleNotFoundError: no module named ‘pip‘ [How to Solve]
- [Solved] ModuleNotFoundError: No module named ‘pip‘
- [Solved] ModuleNotFoundError: No module named ‘xxx’; ‘xxx’ is not a package
- [Solved] modulenotfounderror: no module named ‘torchtext.legacy.data.datasets_ utils‘
- [Solved] scikit-learn Error: ModuleNotFoundError: No module named ‘sklearn.utils.linear_assignment_’
- [Solved] Jupyter notebook use pyLDAvis Error: modulenotfounderror: no module named ‘pyLDAvis’‘
- [Solved] jupyter notebook Error: ModuleNotFoundError: No module named jupyter_nbextensions_configurator
- [Mac M1] How to Solve import wordcloud Error: ModuleNotFoundError: No module named ‘wordcloud‘
- Python AttributeError: module ‘tensorflow‘ has no attribute ‘InteractiveSession‘
- Python Pandas Error: No module named ‘openpyxl‘
- [Solved] Python Project Import Module Error: ModuleNotFoundError
- Module not found error: no module named ‘filefolder’ appears when learning engineering knowledge
- [Solved] R Error: Python module tensorflow.keras was not found.