Pycharm上的Tensorflow导入错误(Mac)

时间:2016-05-03 18:22:02

标签: python pycharm tensorflow protocol-buffers

enter image description here

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

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

非常感谢!

enter image description here

1 个答案:

答案 0 :(得分: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 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