Search code examples
pythoneclipsemacospydevtensorflow

TensorFlow with Eclipse


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?


Solution

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