from tensorflow.examples.tutorials.mnist import input_data,examples标红报错。from tensorflow_core.examples.tutorials.mnist import input_data,tutorials标红报错,终极解决办法。
#报错原因
一般低版本的tensorflow不会报错,高版本的tensorflow,比如2.0版本就会报错。这是因为在tensorflow文件的exampls中缺乏tuorials文件。
#解决办法
在tensorflow-master 文件中找到exampls文件下的tuorials文件,将该文件添加到虚拟环境tensorflow中,就可以了。
1、下载 tensorflow-master 文件
首先提前下载 tensorflow-master 文件。百度云盘连接如下:
链接:https://pan.baidu.com/s/12mx_3gG3c3LWV9MQITfJsw
提取码:1122
下载好文件解压,找到exampls文件,路径为:
tensorflow-master\tensorflow-master\tensorflow\examples
2、from tensorflow.examples.tutorials.mnist import input_data,报错解决办法:
在创建的虚拟环境中,找到tensorflow,添加exampls文件。以我的为例,创建的虚拟环境中,tensorflow文件路径为:
D:\Python3.6\Lib\site-packages\tensorflow
注:我的虚拟环境在D:\Python3.6。每个人的虚拟环境路径不一样。
最后将上面在百度云盘里下载的文件里的examples文件,直接复制到tensorflow文件夹中。