带有Tensorflow的Anaconda:没有名为any_pb2的模块

时间:2016-02-25 13:08:15

标签: python anaconda tensorflow

我刚刚在Ubuntu 14.04中安装了Anaconda。然后我用

安装了tensorflow
conda install -c https://conda.anaconda.org/jjhelmus tensorflow

然后我安装了protobuf

conda install -c https://conda.anaconda.org/anaconda protobuf

但是,我无法解决这个问题:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/daniel/anaconda2/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)
  File "/home/daniel/anaconda2/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
    builtins.execfile(filename, *where)
  File "/home/daniel/Documents/Cursos/UnB/Metodos Computacionais/2016/Notas de Aula/Part II - Aula 1 Regression Linear Models/biasVersusVarianceSeveralData.py", line 8, in <module>
    import tensorflow as tf
  File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 69, in <module>
    from tensorflow.python.training import training as train
  File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/training.py", line 149, in <module>
    from tensorflow.python.training.saver import generate_checkpoint_state_proto
  File "/home/daniel/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 29, in <module>
    from google.protobuf.any_pb2 import Any
ImportError: No module named any_pb2

4 个答案:

答案 0 :(得分:4)

发布此内容以防其他人帮助。尝试使用conda TensorFlow包在Spyder的IPython控制台中导入TensorFlow时遇到了同样的问题。我能够通过卸载conda包来解决这个问题:

conda uninstall tensorflow

然后使用 pip 安装:

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl --ignore-installed

注意最终标志,没有标志我收到有关 easy-install.pth 的错误消息,安装将失败。希望这有助于其他人! Credit to frankcarey for the fix.

答案 1 :(得分:1)

使用instructions on the TensorFlow site

TLDR;

我将此作为答案发布,因为人们不会在评论中寻找答案。

答案 2 :(得分:1)

以下是我对github问题的评论,希望这会有所帮助。

“对于遇到同样问题的其他人来说,当我尝试通过jupyter在笔记本上导入tensorflow时,我也遇到了类似的问题。这些模块是使用conda安装的。在花了两天时间没有任何成功(不断获得)同样,没有任何模块any_pb2 / contrib),很明显这是一个笔记本问题,而不是张流关系,因为我可以从python shell导入tensorflow。所以我决定切换回vanilla python并手动安装所有东西(tensorflow via pip&amp;摆脱jupyter&amp;安装ipython而现在我能够从我的ipython笔记本导入tensorflow。“

原始评论链接:https://github.com/tensorflow/tensorflow/issues/1161#issuecomment-188664103

答案 3 :(得分:-1)

以下对我有用:

conda install -c https://conda.anaconda.org/jjhelmus tensorflow