Python目标检测项目导入自定义模块遇ModuleNotFoundError求助
解决ModuleNotFoundError: No module named 'supervision.tools'的问题
问题原因
supervision库在0.19.0版本后重构了模块结构,旧的supervision.tools和supervision.draw路径被移除,统一为直接从supervision根模块导入相关类。
解决步骤
步骤1:确认supervision版本
执行以下命令查看当前安装的版本:pip show supervision如果版本≥0.19.0,直接修改导入语句;如果是旧版本且不想升级,可跳过步骤2直接执行步骤3。
步骤2:修改导入语句(推荐)
将代码中的旧导入:from supervision.draw.color import ColorPalette from supervision.tools.detections import Detections, BoxAnnotator替换为新版本的导入方式:
from supervision import ColorPalette, Detections, BoxAnnotator步骤3:安装指定旧版本(可选)
若需保留旧版模块结构,执行命令安装0.18.0版本:pip install supervision==0.18.0额外检查
确保已正确安装supervision库,未安装则执行:pip install supervision
内容的提问来源于stack exchange,提问作者Yahya Haj Ali
相关产品推荐
相关产品推荐

