Pycharm上的Tensorflow导入错误(Mac)

Bil*_*ack 6 python protocol-buffers pycharm tensorflow

在此输入图像描述

错误消息(请查看截图):

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
Run Code Online (Sandbox Code Playgroud)

非常感谢 !

在此输入图像描述

HEA*_*0NE 1

我尝试使用以下示例代码重现您遇到的问题:

import tensorflow as tf
hello = tf.constant('Hello, Tensorflow!')
Run Code Online (Sandbox Code Playgroud)

但我没能做到。我可以在 PyCharm 和命令行 ( exit code 0) 中毫无问题地运行该脚本。

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

numpy==1.11.0
protobuf==3.0.0b2
six==1.10.0
Run Code Online (Sandbox Code Playgroud)

我在 Mac OS X 10.11.4 上使用 PyCharm Community Edition 2016.1.2 和 Python 2.7.10


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

对于 Python 2、Mac OS X,这是安装命令: pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl