Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow is not installed properly

I am a beginner and I tried installing tensor flow on Macbook according to the instructions given on the site.

sudo easy_install pip
sudo easy_install --upgrade six
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl

After installation , when I am trying to import tensor flow , I am getting the following error:

    >>> import tensorflow
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 50, in <module>
    from tensorflow.python.framework.framework_lib import *
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/framework_lib.py", line 62, in <module>
    from tensorflow.python.framework.ops import Graph
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 40, in <module>
    from tensorflow.python.framework import versions
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/versions.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
>>> 

I am new to python and I have tried a few solutions on internet but none of them have worked so far. Perhaps the error is due to the pip installation. I am stuck on this since 2 days. Thanks for help!

like image 890
Rohan Chauhan Avatar asked Oct 18 '22 18:10

Rohan Chauhan


2 Answers

To add onto the previous answer - on my OSX machine (10.11), I found two factory installations of numpy - one in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy and the other in /Library/Python/2.7/site-packages/numpy/. As far as I can tell, pip will upgrade the one in /Library, but python kept trying to use the one in /System/Library/ first.

As a temporary solution, I just renamed the numpy folder in /System/Library to numpy.old. Tensorflow imported correctly after that.

like image 145
Lee Cheng Avatar answered Nov 04 '22 19:11

Lee Cheng


I think I came across the same problem. This was caused by an earlier version of factory-included numpy that on the factory-installed Python on Max OSX.

I tried sudo pip uninstall numpy and the factor-included numpy still exists. To solve this problem, I upgraded the factory-included numpy using easy_install, then used pip to install tensorflow and it worked:

sudo easy_install -U numpy
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl
like image 33
Zichen Wang Avatar answered Nov 04 '22 20:11

Zichen Wang