当我尝试使用 PIP 安装库时,出现 AttributeError: module 'collections' has no attribute 'Iterable'

问题描述 投票:0回答:3

我刚刚在我的新电脑上安装了 python3 并尝试使用

numpy
安装一些库(
cython
cymem
pip
),我得到了

AttributeError: module 'collections' has no attribute 'Iterable'

但是像

nltk
cytest
这样的库安装没问题

python numpy cython cythonize
3个回答
11
投票

collections.Iterable 已弃用。 将其替换为 collections.abc.Iterable。

请参阅此答案以了解兼容性: https://stackoverflow.com/a/53978543/13369176


0
投票

由于这是一个通常出现在库代码中的问题,而不是我的代码,因此快速修复可能是而不是

import collections

import collections.abc as collections

并在各自项目的存储库中填写错误。


0
投票

解决方案是这样做:

import collections
collections.Iterable = collections.abc.Iterable

在这里找到:https://github.com/quandyfactory/dicttoxml/issues/91

© www.soinside.com 2019 - 2024. All rights reserved.