6

enter image description here

Error msg (check the screenshot picture please):

ImportError: cannot import name symbol_database

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.

Process finished with exit code 1

Thanks a lot !

enter image description here

linusg
  • 6,289
  • 4
  • 28
  • 78
Ancalagon BerenLuthien
  • 1,154
  • 6
  • 20
  • 29

1 Answers1

1

I tried to reproduce the problem you're running into using this sample code:

import tensorflow as tf
hello = tf.constant('Hello, Tensorflow!')

But I was not able to. I can run the script without issues within PyCharm and in my command line (exit code 0).

These are the packages (and their version) that are required for tensorflow 0.8.0 to work:

numpy==1.11.0
protobuf==3.0.0b2
six==1.10.0

I'm using PyCharm Community Edition 2016.1.2 and Python 2.7.10 on Mac OS X 10.11.4


How did you install tensorflow? You should install it via pip (as recommended by the site: https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#pip-installation)

For Python 2, Mac OS X, this is the installation command: pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl

HEADLESS_0NE
  • 3,416
  • 4
  • 32
  • 51
  • My protobuf version was not latest. After upgrading protobuf to 3.0.0b2, problem solved. / Just one note for other people who may have similar problem: in Pycharm -- Preferences -- Project Interpreter, each package shows two columns: Version column and Latest column. Click "+" and search for "package name" (protobuf in my case), then MUST CLICK "SPECIFY VERSION" as the version wanted (3.0.0b2.post2 in my case), and then install. Otherwise, the version will not change to 3.0.0b2. – Ancalagon BerenLuthien May 03 '16 at 19:06
  • Is there no way to get PyCharm to automatically install tensorflow from https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl? Is it necessary to use pip from terminal to install it? – faridghar May 26 '16 at 17:51
  • Most likely not. https://storage.googleapis.com/tensorflow/mac/ is not a Python package index repository. If it was, however, you could have added it to PyCharm's list of repositories. `Preferences > Project > Project Interpreter > "+" button > Manage repositories` – HEADLESS_0NE May 27 '16 at 20:13