TensorFlow with Eclipse

a 夏天 提交于 2019-12-23 21:23:06

问题


I'm trying to run the TensorFlow Python examples for with Eclipse Mars for Mac OS X, but I'm getting the following error:

Unresolved import: tensorflow.python.platform 

The error is raised on the 3rd line:

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.

I installed TensorFlow following the installation directions on the TensorFlow website.

What am I missing?


回答1:


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:

  1. 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.)

  2. 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.




回答2:


  1. install tensorflow.
  2. in eclipse , assume you have pydev installed, go to preferences>pydev>python interpreter.
  3. in the libraries tab add the path to the lib folder of your tensorflow lib folder.

here is screenshot:




回答3:


I also had import issues. I fixed it by creating a new project and specifying interpreter as ~/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.

The answer from @mrry above was helpful - only the link to the 5 step guide seems to be unavailable. Hope this helps!



来源:https://stackoverflow.com/questions/34883885/tensorflow-with-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!