自 Python 3.10 开始,库 collections 以下各项都停用了,其中就包含了 pygal._compat.py 中的 from collections import Iterator
["Awaitable", "Coroutine", "AsyncIterable", "AsyncIterator", "AsyncGenerator", "Hashable", "Iterable", "Iterator", "Generator", "Reversible", "Sized", "Container", "Callable", "Collection", "Set", "MutableSet", "Mapping", "MutableMapping", "MappingView", "KeysView", "ItemsView", "ValuesView", "Sequence", "MutableSequence", "ByteString"]
需要自己更改 Lib\site-packages\pygal_compat.py` 的内容
【直接复制代码即可修改】
#修改之前的出错代码行
# from collections import Iterable
#修改为以下
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
refer:
importerror cannot import name 'Iterable' from 'collections'-有问必答-CSDN问答