Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow import error: no module named _pywrap_tensorflow

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.

like image 445
kashkar Avatar asked Oct 29 '22 15:10

kashkar


1 Answers

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.

like image 133
ivan_pozdeev Avatar answered Nov 15 '22 05:11

ivan_pozdeev