Pycharm (Mac) 上的 Tensorflow 导入错误

Tensorflow import error on Pycharm (Mac)

错误信息(请查看截图图片):

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

非常感谢!

我试图重现您运行正在使用此示例代码的问题:

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

但是我做不到。我可以 运行 在 PyCharm 和我的命令行 (exit code 0) 中没有问题的脚本。

这些是 tensorflow 0.8.0 工作所需的软件包(及其版本):

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

我在 Mac OS X 10.11.4

上使用 PyCharm 社区版 2016.1.2 和 Python 2.7.10

你是怎么安装的tensorflow 您应该通过 pip 安装它(按照网站的建议:https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#pip-installation

对于Python2,MacOSX,这是安装命令: pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl