带有 Eclipse 的 TensorFlow
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34883885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TensorFlow with Eclipse
提问by Eddy
I'm trying to run the TensorFlow Python examples for with Eclipse Mars for Mac OS X, but I'm getting the following error:
我正在尝试使用 Eclipse Mars for Mac OS X 运行 TensorFlow Python 示例,但出现以下错误:
Unresolved import: tensorflow.python.platform
The error is raised on the 3rd line:
错误出现在第 3 行:
from __future__ import absolute_import
from __future__ import print_function
import tensorflow.python.platform
I'm new to Python and TensorFlow. I'm using PyDev for Eclipse. I read somewhere that I can add code to the "External Libraries" folder but I'm not sure where the TensorFlow library is.
我是 Python 和 TensorFlow 的新手。我在 Eclipse 中使用 PyDev。我在某处读到可以将代码添加到“外部库”文件夹中,但我不确定 TensorFlow 库在哪里。
I installed TensorFlow following the installation directions on the TensorFlow website.
我按照 TensorFlow 网站上的安装说明安装了 TensorFlow。
What am I missing?
我错过了什么?
回答by mrry
It sounds like you are running into a problem with your Python environment. The easiest way to deal with this is to follow these steps:
听起来您的 Python 环境有问题。处理此问题的最简单方法是执行以下步骤:
Install TensorFlow into a virtualenv, by following the instructions here. This avoids the need to acquire root privileges, and makes it easier to experiment with different versions of TensorFlow. (It also avoids conflicts with other system-installed versions of different libraries.)
Set up PyDev to use your new virtualenv, by following step 5 onwards in this guide. This involves setting up a new "interpreter" whose library will be the set of libraries in the virtualenv. You may need to recreate your Eclipse project to use this interpreter.
回答by amr koura
- install tensorflow.
- in eclipse , assume you have pydev installed, go to preferences>pydev>python interpreter.
- in the libraries tab add the path to the lib folder of your tensorflow lib folder.
- 安装张量流。
- 在 eclipse 中,假设您已经安装了 pydev,请转到首选项>pydev>python 解释器。
- 在库选项卡中,将路径添加到 tensorflow lib 文件夹的 lib 文件夹中。
回答by Gal_M
I also had import issues. I fixed it by creating a new project and specifying interpreter as ~/tensorflow/lib/python2.7
我也有进口问题。我通过创建一个新项目并将解释器指定为 ~/tensorflow/lib/python2.7 来修复它
Eclipse seems to then point to the right interpreter and offers to import other relevant files - result is similar to answer above.
Eclipse 似乎然后指向正确的解释器并提供导入其他相关文件 - 结果类似于上面的答案。
The answer from @mrry above was helpful - only the link to the 5 step guide seems to be unavailable. Hope this helps!
上面@mrry 的回答很有帮助 - 只有 5 步指南的链接似乎不可用。希望这可以帮助!