我正在尝试使用适用于 Mac OS X 的 Eclipse Mars 运行 TensorFlow Python 示例,但出现以下错误:
Unresolved import: tensorflow.python.platform
错误出现在第 3 行:
from __future__ import absolute_import
from __future__ import print_function
import tensorflow.python.platform
我是 Python 和 TensorFlow 的新手。我正在为 Eclipse 使用 PyDev。我在某处读到可以将代码添加到“外部库”文件夹,但我不确定 TensorFlow 库在哪里。
我在 installation directions on the TensorFlow website 之后安装了 TensorFlow .
我错过了什么?
最佳答案
听起来您遇到了 Python 环境问题。处理此问题的最简单方法是执行以下步骤:
按照说明将 TensorFlow 安装到虚拟环境中 here .这避免了获取 root 权限的需要,并且更容易尝试不同版本的 TensorFlow。 (也避免了与其他系统安装版本不同库的冲突。)
设置 PyDev 以使用新的 virtualenv,按照 this guide 中的第 5 步开始.这涉及设置一个新的“解释器”,其库将是 virtualenv 中的一组库。您可能需要重新创建 Eclipse 项目才能使用此解释器。
关于python - 带有 Eclipse 的 TensorFlow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34883885/