简体   繁体   中英

Jupyter Notebook Tensorflow MNIST import Error: ImportError: cannot import name batching

I tried to execute this line in my application in Jupyter notebook.

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

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.

Based on the error given, make sure you have jupyter installed within the py27 conda environment. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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