0

I have just pip installed tensorflow. Now when I run import tensorflow

AttributeError                            Traceback (most recent call last)
<ipython-input-10-8db4a851c0de> in <module>()
----> 1 import tensorflow as tf
      2 from tensorflow import keras
      3 
      4 import numpy as np
      5 import matplotlib.pyplot as plt

~/.local/lib/python3.6/site-packages/tensorflow/__init__.py in <module>()
     22 
     23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
     25 
     26 try:

~/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py in <module>()
     45 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
     46 
---> 47 import numpy as np
     48 
     49 from tensorflow.python import pywrap_tensorflow

~/.local/lib/python3.6/site-packages/numpy/__init__.py in <module>()
    140     from . import _distributor_init
    141 
--> 142     from . import core
    143     from .core import *
    144     from . import compat

~/.local/lib/python3.6/site-packages/numpy/core/__init__.py in <module>()
     57 from . import numerictypes as nt
     58 multiarray.set_typeDict(nt.sctypeDict)
---> 59 from . import numeric
     60 from .numeric import *
     61 from . import fromnumeric

~/.local/lib/python3.6/site-packages/numpy/core/numeric.py in <module>()
   3091 from .umath import *
   3092 from .numerictypes import *
-> 3093 from . import fromnumeric
   3094 from .fromnumeric import *
   3095 from . import arrayprint

~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in <module>()
     15 from . import numerictypes as nt
     16 from .numeric import asarray, array, asanyarray, concatenate
---> 17 from . import _methods
     18 
     19 _dt_ = nt.sctype2char

~/.local/lib/python3.6/site-packages/numpy/core/_methods.py in <module>()
    156     )
    157 
--> 158 _NDARRAY_ARRAY_FUNCTION = mu.ndarray.__array_function__
    159 
    160 def _array_function(self, func, types, args, kwargs):

AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'

I have already tried uninstalling and reinstalling numpy. I have numpy-1.16.0

I have seen a few other questions that seem similar. However this is not a duplicate none of them addresses my issue. I get an error just on importing tensorflow.

1

1 Answer 1

2

Simply run this, solved for me:

pip uninstall numpy
pip install numpy

or

pip uninstall numpy
pip install numpy==1.15.4
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.