python - Jupyter Notebook Tensorflow MNIST 导入错误 : ImportError: cannot import name batching

标签 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 中的错误

最佳答案

我在从jupyter笔记本导入库时遇到了类似的问题,问题一直是我忘记在新的conda环境中安装jupyter,但jupyter安装在根环境中。

根据给出的错误,确保您已在 py27 conda 环境中安装了 jupyter。如果没有安装,会默认在root环境下打开。

所以在终端中:

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

关于python - Jupyter Notebook Tensorflow MNIST 导入错误 : ImportError: cannot import name batching,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52728981/

相关文章:

python - 尝试使用 pip 在 ubuntu 12.04 上安装 pymssql

python 'and' boolean 运算符

python - 在调试期间检查常量或变量张量的值

python-3.x - Python 项目的预提交 Hook 失败

python-3.x - DataFrame' 对象没有属性 'sort'

python - 使用 IAM 角色凭证通过 Python 卸载到 S3

python - Boost.Python:如何公开 std::unique_ptr

python - tensorflow 相对于 numpy 的一般计算优势

python - 使用 Tensorflow 的 tf.data API 为训练和验证设置不同的批量大小

python - Conda install some-package hangs with (Solving environment : failed)