ImportError: numpy.core.multiarray failed to import

7,541 views
Skip to first unread message

flyaway

unread,
Nov 17, 2015, 7:56:57 AM11/17/15
to dis...@tensorflow.org
Hi, guys

I have installed the tensorflow successfully on my Linux system. But when I  run “ import tensorflow as tf ” under python2.7, I got the Error:

RuntimeError: module compiled against API version 9 but this version of numpy is 7
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zhouyc/tensorflow/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "/home/zhouyc/tensorflow/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 22, in <module>
    from tensorflow.python.client.client_lib import *
  File "/home/zhouyc/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/client_lib.py", line 35, in <module>
    from tensorflow.python.client.session import InteractiveSession
  File "/home/zhouyc/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 11, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "/home/zhouyc/tensorflow/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/zhouyc/tensorflow/lib/python2.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 sure I have numpy1.9.2 installed….. 

Can any one give me some advice ?


flyaway




Derek Murray

unread,
Nov 17, 2015, 11:58:56 AM11/17/15
to flyaway, Discuss
Is it possible that you have two versions of numpy installed, and it's picking up the wrong version from your path? The error message indicates that the wrong version of numpy (an old version) is being loaded.

Derek.

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/84BE07C6-B10D-4EB9-B6CD-F2ED98A1F1F0%40gmail.com.

flyaway

unread,
Nov 17, 2015, 9:07:14 PM11/17/15
to Derek Murray, Discuss
Cool ! 

I have reinstall the numpy1.10.1 and problem solved ! 

Thanks  a lot !

flyaway



alipio...@gmail.com

unread,
Nov 25, 2015, 12:48:42 PM11/25/15
to Discuss
In my case (using mac OS) reinstalling numpy version 1.10 with pip was not enough because pip installs in 

/Library/Python/2.7/site-packages


and I had numpy 1.6 simultaneously in a different location 

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

When importing tensorflow this was the location first sought for numpy (you can check that with sys.path).

Solution: I had to manually remove numpy from this other location not used by pip with "sudo rm .r numpy". Then just restart python.

Alípio

manoj...@gmail.com

unread,
Dec 16, 2015, 6:44:34 PM12/16/15
to Discuss
Thanks for the post. I faced the same issue. By removing the numpy directory   by "sudo rm .r numpy" resolved the issue.

wlsh...@gmail.com

unread,
Dec 29, 2015, 2:23:45 AM12/29/15
to Discuss, manoj...@gmail.com
I faced the same problem. And I have no idea to follow the instruction by @Alípio 
Do you know how to fix this step by step?

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python -> numpy 1.8
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python -> numpy 1.6
ls /Library/Python/2.7/site-packages -> numpy 1.10.2 

my python version 2.7.10 

Thanks 

manoj...@gmail.com於 2015年12月17日星期四 UTC+8上午7時44分34秒寫道:
Reply all
Reply to author
Forward
0 new messages