gpt4 book ai didi

python-3.x - 属性错误 : 'tuple' object has no attribute 'type' upon importing tensorflow

转载 作者:行者123 更新时间:2023-12-04 14:22:22 27 4
gpt4 key购买 nike

我在 these 之后将 Tensorflow(-gpu) 1.8.0 版安装为 pip 包指示。安装后,我打开一个python3控制台并输入

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 中有它

有人可以帮我吗?

最佳答案

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

对我来说,我做到了

pip uninstall numpy
sudo apt-get purge python3-numpy

然后我不得不去 /usr/local/lib/python3.6/dist-packages并删除由于某种原因仍然存在的 numpy 文件夹。之后,重新安装numpy
pip install numpy

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

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

关于python-3.x - 属性错误 : 'tuple' object has no attribute 'type' upon importing tensorflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200850/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com