[Solution] Problem: ImportError: cannot import name ‘Callable‘ from ‘collections‘

question

When I ran yolov8's code, an error occurredImportError: cannot import name 'Callable' from 'collections' a>

reason

Version problem: The following collections methods have been canceled after Python 3.10 version

 ["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"]

solve

"from collections import ***". Before version 3.6, there was no need to add .abc after collections. After 3.7, you will be reminded to add .abc. Now version 3.10 stops using the case without adding .abc.

So the correct way to write it should be "from collections.abc import ***", according to the error message in the picture above, the red box Need to modify and add .abc.

Guess you like

Origin blog.csdn.net/weixin_45662399/article/details/134501374