AttributeError:导入张量流时,'tuple'对象没有属性'type' [英] AttributeError: 'tuple' object has no attribute 'type' upon importing tensorflow

查看:307
本文介绍了AttributeError:导入张量流时,'tuple'对象没有属性'type'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这些说明进行安装了Tensorflow(-gpu)1.8.0版作为pip软件包. .安装后,我打开了一个python3控制台并输入

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

此后,出现以下错误

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'

在StackOverflow上报告的外观相似的问题的答案是,版本> 1.7似乎没有此问题.但我似乎在1.8中有它

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

有人可以帮我吗?

推荐答案

实际上,这意味着您以某种方式安装了numpy的多个版本(或者有多个重叠的版本).您需要确保从系统中完全卸载了numpy,然后重新安装.

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.

对我来说,我做到了

pip uninstall numpy
sudo apt-get purge python3-numpy

然后我必须去/usr/local/lib/python3.6/dist-packages并删除由于某些原因仍然存在的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

工作.这是我在上面打开的github问题:

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

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

这篇关于AttributeError:导入张量流时,'tuple'对象没有属性'type'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆