rj487
rj487

Reputation: 4634

Import tensorflow error on mac

Enviorment:

Mac OSX 10.10

Python: 2.7.10

I have following error when I was trying to import tensorflow

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
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 "/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 48, 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 was following the official install pege, and typed these two command

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl

$ sudo pip install --upgrade $TF_BINARY_URL

I've tried uninstall tensorflow and protobuf,and then reinstall tensorflow, but it threw the same error.

Update

After I uninstall numpyandtensorflow, I reinstall numpy.However, I couldn't reinstall tensorflow.

It threw this

$sudo  pip install --upgrade $TF_BINARY_URL
The directory '/Users/Coda/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/Coda/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You must give at least one requirement to install (see "pip help install")

Is that because I uninstall tensorflow wrongly? I use pip uninstall tensorflow to uninstall.

Upvotes: 0

Views: 1390

Answers (1)

aneroid
aneroid

Reputation: 15962

I think the issue is that your numpy is one version older than needed (0x9 = 9; 0xa = 10). Maybe upgrade numpy and see if importing tensorflow works after that.

Edit/Update: For your new error, try the pip install with the --no-cache-dir option.

Upvotes: 1

Related Questions