5

I'm trying to set up TensorFlow on Mac following the TensorFlow install docs.

However after completing the outlined steps and trying "import tensorflow as tf", I'm getting the following error trace:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 21, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _pywrap_tensorflow

I have already installed and used TensorFlow on my machine before and never encountered this issue.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
kashkar
  • 663
  • 1
  • 8
  • 22

1 Answers1

2

This part looks wrong:

File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)

It uses pywrap_tensorflow from Python installation at /usr/local/lib/python2.7 but importlib from the one at /usr/local/Cellar/python/2.7.9.

There must be something wrong with your Python package search path. See e.g. Keras import error Nadam for troubleshooting tips.

Community
  • 1
  • 1
ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152