Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numpy version error when importing tensorflow

I have executed pip install for tensorflow.

Under the python command line environment, when I tried

import tensorflow as tf

I met the following errors:

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 "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-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 have checked my numpy version using print numpy.__version__. It showed "1.8.2". So, what should I do now? Thanks!

like image 720
ReadyOrNot Avatar asked Oct 30 '22 19:10

ReadyOrNot


1 Answers

From the error, it looks like you're running python 2.7 from usr/local/bin. There is a mismatch problem between your numpy version and tensorflow installation. I'd recommend you to install anaconda since it will make sure that correct version of tensorflow that is compatible with your numpy version be installed.

Once you have anaconda, then do:

conda install -c conda-forge tensorflow
like image 89
kmario23 Avatar answered Nov 15 '22 05:11

kmario23