tensorflow: Can't import tensorflow 0.7.1 It thinks I'm importing from source dir.

For bugs/issues, please fill in the following. The more information you provide, the more likely we can help you.

Environment info

Operating System: Ubuntu 64bit CUDA: 7.5

If installed from binary pip package, provide: I tried installing using both pip CPU and GPU (making sure I uninstalled the previous first):

$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp34-none-linux_x86_64.whl

$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.7.1-cp34-none-linux_x86_64.wh

Logs or other output that would be helpful

I get the following error using the new 0.7.1 wheel, although it is fine with the previous one 0.7.0

(If logs are large, please upload as attachment).
In [1]: import tensorflow as tf
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-41389fad42b5> in <module>()
----> 1 import tensorflow as tf

/home/eders/anaconda/lib/python2.7/site-packages/tensorflow/__init__.py in <module>()
     21 from __future__ import print_function
     22
---> 23 from tensorflow.python import *

/home/eders/anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py in <module>()
     39 please exit the tensorflow source tree, and relaunch your python interpreter
     40 from there.""" % traceback.format_exc()
---> 41   raise ImportError(msg)
     42
     43 from tensorflow.core.framework.summary_pb2 import *

ImportError: Traceback (most recent call last):
  File "/home/eders/anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 35, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/eders/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
ImportError: No module named protobuf


Error importing tensorflow.  Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.

Note that I don’t even have the source files on my computer. Any idea of what it might be? Thanks for the help.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24

Commits related to this issue

Most upvoted comments

@xiao-cheng Yes. I did the same unintentionally. I ended up pip uninstalling tensorflow AND pip uninstalling protobuf, and then just pip installed tensorflow and it worked.

For anyone reading, I did this through a Python 2.7 virtual env created in Anaconda.

Code:

$ pip uninstall tensorflow $ pip uninstall protobuf $ pip install tensorflow

Upgrading to protobuf 3.0.0 from 3.0.0b seemed to solve this for me. Just did: pip install protobuf --upgrade

I have this same Error. When I pip install protobuf it says my requirements are satisfied but I still get the error. Any ideas?

I’m doing it on a windows machine. None of the solutions given above worked for me; except I haven’t yet tried through conda.