Jupyter Notebook Tensorflow MNIST导入错误:ImportError:无法导入名称批处理

时间:2018-10-09 20:39:53

标签: python tensorflow anaconda jupyter-notebook

我试图在Jupyter笔记本的应用程序中执行此行。

from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets

我收到以下错误:

.conda/envs/py27/lib/python2.7/site-packages/tensorflow/contrib/__init__.py in <module>()
     23 
     24 # Add projects here, they will show up under tf.contrib.
---> 25 from tensorflow.contrib import batching
     26 from tensorflow.contrib import bayesflow
     27 from tensorflow.contrib import cloud

ImportError: cannot import name batching

如果我这样运行它,我不会收到此错误:

 python -c "from tensorflow.examples.tutorials.mnist import input_data"

有人可以告诉我是什么引起了Jupyter Notebook中的错误

1 个答案:

答案 0 :(得分:0)

我从jupyter Notebook导入库时遇到了类似的问题,问题一直是我忘记在新的conda环境中安装import java.util.Scanner; public class HWFive { public static int sumDigits(int number) { int sum = 0; while(number > 0) { sum = sum + number % 10; number = number / 10; } return sum; } public static int numLowerCase(String str) { int numLower = 0; int index = 0; char ch; while (index < str.length()){ ch = str.charAt(index); if('a' <= ch && ch <= 'z'){ numLower++; } index++; } return numLower; } public static void main(String[] args){ Scanner s = new Scanner(System.in); System.out.print("Please enter a number:"); int number = s.nextInt(); number = sumDigits(number); System.out.println("The sum of all digits is: " + number); System.out.print("Please enter a Word: "); String str = s.nextLine(); (str) = numLowerCase(str); System.out.println("The sum of all digits is: " + str); } } ,但是jupyter是在根环境中安装的。

根据给出的错误,确保在jupyter conda环境中安装了jupyter。如果未安装,则默认在根环境中打开一个。

所以在终端:

py27