我在运行yolov8的代码时,出现了ImportError: cannot import name 'Callable' from 'collections'的错误
版本问题:以下collections的方法都在Python3.10版本后被取消了
["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"]
”from collections import ***“,在3.6版本之前collections后面是不需要带.abc的,3.7之后就会提醒需要加.abc,现在3.10版本停止使用不加.abc的情况。
所以正确的写法应该是“from collections.abc import ***",根据上图的错误提示,红框内需要修改添加.abc。