简体   繁体   English

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

[英]Jupyter Notebook Tensorflow MNIST import Error: ImportError: cannot import name batching

I tried to execute this line in my application in Jupyter notebook. 我试图在Jupyter笔记本的应用程序中执行此行。

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

I get the following error: 我收到以下错误:

.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

I do not get this error if I ran it like this: 如果我这样运行它,我不会得到此错误:

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

Can someone tell me what's causing the error in Jupyter Notebook 有人可以告诉我是什么引起了Jupyter Notebook中的错误

I have run into similar issue with importing libraries from jupyter notebook, and the problem has always been that I forgot to install jupyter in my new conda environment, but jupyter is installed in the root environment. 从jupyter Notebook导入库时遇到了类似的问题,问题一直是我忘记在新的conda环境中安装jupyter ,但jupyter是在根环境中安装的。

Based on the error given, make sure you have jupyter installed within the py27 conda environment. 根据给出的错误,确保在py27环境中安装了py27 If it not installed, it will default to open the one in the root environment. 如果未安装,则默认在根环境中打开一个。

So in the terminal: 因此在终端中:

source activate py27  # activate py27 if on windows
conda install jupyter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM