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
(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) # 打印训练样例的标签 print("Example training data label:", mnist.train.labels)
, 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.
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 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.
- The lenet model trained by Python failed to predict its own handwritten pictures
- Mxnet Export onnx Symbol and params files provided are invalid
- [Solved] RuntimeError: Numpy is not available (Associated Torch or Tensorflow)
- ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
- [Perfectly Solved] attributeerror: module ‘SciPy. Misc’ has no attribute ‘toimage’ error
- Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]
- Error:output with shape [1, 224, 224] doesn‘t match the broadcast shape [3, 224, 224]
- An introduction to sys modules in Python and how packages are imported and used
- [Solved] AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘AdampOptimizer‘
- Tensorflow: Common Usage of tf.get_variable_scope()
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- [Solved] Python Keras Error: AttributeError: ‘Sequential‘ object has no attribute ‘predict_classes‘
- How to Solve Opencv Reads Video Error: cv2.error
- Tensorflow import Error: ImportError: libcuda.so.1: cannot open shared object file: No such file or dire
- [Solved] Python Error: An attempt has been made to start a new process before the current process has finished …
- The PIP installation package was successful but the import failed
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
- [Solved] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
- [Solved] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter st
- [Solved] R Error: Python module tensorflow.keras was not found.