8

I'm trying to get TensorFlow to work on my Mac (OSX El Capitan 10.11.2). I tried the pip install from the setup guide and also followed the instructions in the accepted answer here.

In both cases I am able to successfully activate the virtualenv and my prompt changes to tensorflow. Python works fine, I'm able to do simple computations on the command line. But when I try to import tensorflow:

import tensorflow as tf

I repeatedly get this error:

ImportError: No module named tensorflow

Any help would be appreciated.

Community
  • 1
  • 1
Eddy
  • 3,533
  • 13
  • 59
  • 89
  • 1
    Can you check if the `lib/python2.x/site-packages/tensorflow` directory is present in your virtualenv dir? – SimoV8 Jan 21 '16 at 08:43
  • It's not. What happened? – Eddy Jan 21 '16 at 09:48
  • It means you have not installed tensorflow in the virtualenv, maybe you installed it in the system environment. – SimoV8 Jan 21 '16 at 09:51
  • you have to run `pip install tensorflow-0.5.0-py2-none-any.whl` after you have activated virtualenv. – SimoV8 Jan 21 '16 at 09:53
  • I tried from inside the tensorflow (virtualenv) directory and got an error. Not sure it's fatal but anyway there is still no tensorflow directory in the location. The error: Detected a distutils installed project ('numpy') which we cannot uninstall. The metadata provided by distutils does not contain a list of files which have been installed, so pip does not know which files to uninstall. – Eddy Jan 21 '16 at 10:34
  • Do you still get this error message if you do `source bin/activate; pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl` from inside your virtualenv directory? – mrry Jan 21 '16 at 16:07
  • When I try the pip install I get tensorflow-0.6.0-cp27-none-linux_x86_64.whl is not a supported wheel on this platform. My OS is Mac El Capitain. I tried changing the "linux" strings into "osx" but I get the same error. – Eddy Jan 21 '16 at 21:59
  • Ah, my apologies. What about if you try `source bin/activate; pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl` from inside your virtualenv directory? – mrry Jan 22 '16 at 16:48
  • I'm getting this error: "Detected a distutils installed project ('numpy') which we cannot uninstall. The metadata provided by distutils does not contain a list of files which have been installed, so pip does not know which files to uninstall." I'm not sure if it's related but now there's a google directory inside python2.7/site-packages -- but still no tensorflow directory. – Eddy Jan 22 '16 at 17:15

1 Answers1

1

I had the issue reported in the original question. Python worked fine, I followed the installation steps on the Tensforflow website, and got "No module named tensorflow."

Re-installing python via brew, and re-installing pip as a result, fixed it. I didn't need to uninstall anything, just the line below along with the normal pip install from the tensorflow installation document afterwards:

brew install python
Eric C. Bohn
  • 809
  • 5
  • 10