6

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/__init__.py", 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/__init__.py", line 47, in <module>
    import numpy as np
  File "/home/px2/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 57, in <module>
    from . import numerictypes as nt
  File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/numerictypes.py", line 111, in <module>
    from ._type_aliases import (
  File "/home/px2/.local/lib/python3.5/site-packages/numpy/core/_type_aliases.py", 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/_type_aliases.py", 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?

4 Answers 4

8

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:

https://github.com/numpy/numpy/issues/12775

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, but I broke my setup beyond repair, so I restored the OS. Since I'm not able to verify the answer, I'll trust you and accept
I see. I recommend sticking with 1.15.4 for your numpy version right now -- seems like 1.16.0 has issues with pandas dataframes with object datatypes writing hdf5 files.
Understood. Thanks again!
Actually, after submitting the bug report, it seems like it is an issue with the tables library, not numpy. Still though, if you work with hdf5 files, I'd stick with numpy 1.15.4 until a tables patch is released.
Had similar problem, it helped. Nevertheless need to be careful as apt-get purge can uninstall some other libraries dependent on numpy. For me it uninstalled few of them, I installed them again by pip.
1

Had the same issue, fixed by going back to Numpy 1.15.4 Thanks wordsforthewise

Comments

0

I can't help you but I can point out another thread with a similar issue: Error with calling Numpy, Scipy, Gensim in python3

Comments

0

This is slightly late, but for anyone running into this issue, what fixed it for me was going into my /anaconda3/lib/python3.X/site-packages folder and manually removing numpy there. Replace python3.X with you version of course.

I also followed Wordsforthewise' suggestion and ran his first two commands before reinstalling numpy via pip. I ran into this problem on a google cloud shell.

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.