AttributeError: 'tuple' object has no attribute 'type' upon importing tensorflow

  • A+

I installed the Tensorflow(-gpu) version 1.8.0 as a pip package following these instructions. Upon installation, I opened a python3 console and typed in

import tensorflow as tf 

Upon which,I get the following error

Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "/home/px2/.local/lib/python3.5/site-packages/tensorflow/", line 24, in <module>     from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import   File "/home/px2/.local/lib/python3.5/site-packages/tensorflow/python/", line 47, in <module>     import numpy as np   File "/home/px2/.local/lib/python3.5/site-packages/numpy/", line 142, in <module>     from . import core   File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/", line 57, in <module>     from . import numerictypes as nt   File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/", line 111, in <module>     from ._type_aliases import (   File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/", line 63, in <module>     _concrete_types = {v.type for k, v in _concrete_typeinfo.items()}   File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/", line 63, in <setcomp>     _concrete_types = {v.type for k, v in _concrete_typeinfo.items()} AttributeError: 'tuple' object has no attribute 'type' 

A similar looking problem reported on StackOverflow has an answer that versions > 1.7 seems to not have this problem. But I seem to have it in 1.8

Can someone help me out?


In fact, this means you have multiple versions of numpy installed somehow (or there are multiple versions that are overlapping). You need to make sure that numpy is fully uninstalled from your system, then reinstall.

For me, I did

pip uninstall numpy sudo apt-get purge python3-numpy 

Then I had to go to /usr/local/lib/python3.6/dist-packages and delete the numpy folders that were still there for some reason. After that, reinstalling numpy with

pip install numpy 

worked. Here is the github issue I opened on it:


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: