python3.10版本报错ImportError: cannot import name ‘Callable’ from ‘collections’
python3.10版本之后collection库下列各项都废弃了:
["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"]
因此,出现错误需要更改对应引用collection库的代码。
这里以from collections import Callable这个包为例。
这里的代码from collections import Callable
改为from collections.abc import Callable
即可