0

I'm running Mac OS X Yosemite - 10.10.5, I am trying to run tensorflow in Python 2.7.10. When I try to import tensorflow I get this error, I believe it is caused because Numpy is not updated:

$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/krishnachatpar/Library/Python/2.7/lib/python/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/krishnachatpar/Library/Python/2.7/lib/python/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/krishnachatpar/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/krishnachatpar/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/krishnachatpar/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/krishnachatpar/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

Update: When I try to update numpy:

$ pip install numpy --upgrade
Collecting numpy
Using cachedhttp://files.pythonhosted.org/packages/e7/c1/d5c47de35e366b1c2f60da88a24b25d3037b892417c5c3c5398313fb54f5/numpy-1.15.1-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
tensorflow 1.1.0 has requirement six>=1.10.0, but you'll have six 1.4.1 which is incompatible.
Installing collected packages: numpy
Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
kchopper
  • 21
  • 2
  • Try this https://stackoverflow.com/questions/20518632/importerror-numpy-core-multiarray-failed-to-import#21946788 – Ujjwal Sep 14 '18 at 18:31
  • Right. You should update numpy. By the way : any reason for python 2.7, if I read correct from 2015? – SpghttCd Sep 14 '18 at 18:32

2 Answers2

0

You have to upgrade your numpy to the latest version:

pip install numpy --upgrade
Peyman.H
  • 1,819
  • 1
  • 16
  • 26
0

So I figured it out:

I switched to python3, installed numpy and tensorflow:

Tensorflow install command:
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
Collecting tensorflow==0.12.0 from https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl

And tested it in Python and both numpy and tensorflow work.

kchopper
  • 21
  • 2