ModuleNotFoundError: No module named ‘mmcv‘

问题描述:最近在改进YOLOv8代码,出现了这个错误,如代码1,大家都明白这时缺少库,但是我执行pip install mmcv,仍然不行。

Traceback (most recent call last):
  File "C:/Users/aoqia/Desktop/yolov8-paper/ultralytics/yolo8/pose/train.py", line 5, in 
    from ultralytics.nn.tasks import PoseModel
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\__init__.py", line 5, in 
    from ultralytics.hub import start
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\hub\__init__.py", line 5, in 
    from ultralytics.hub.auth import Auth
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\hub\auth.py", line 5, in 
    from ultralytics.hub.utils import HUB_API_ROOT, PREFIX, request_with_credentials
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\hub\utils.py", line 14, in 
    from ultralytics.yolo.utils import (ENVIRONMENT, LOGGER, ONLINE, RANK, SETTINGS, TESTS_RUNNING, TQDM_BAR_FORMAT,
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\yolo\__init__.py", line 3, in 
    from . import v8
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\yolo\v8\__init__.py", line 3, in 
    from ultralytics.yolo.v8 import classify, detect, pose, segment
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\yolo\v8\classify\__init__.py", line 3, in 
    from ultralytics.yolo.v8.classify.predict import ClassificationPredictor, predict
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\yolo\v8\classify\predict.py", line 5, in 
    from ultralytics.yolo.engine.predictor import BasePredictor
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\yolo\engine\predictor.py", line 37, in 
    from ultralytics.nn.autobackend import AutoBackend
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\nn\__init__.py", line 3, in 
    from .tasks import (BaseModel, ClassificationModel, DetectionModel, SegmentationModel, attempt_load_one_weight,
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\nn\tasks.py", line 11, in 
    from ultralytics.nn.modules import (AIFI, C1, C2, C3, C3TR, SPP, SPPF, Bottleneck, BottleneckCSP, C2f, C3Ghost, C3x,
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\nn\modules\__init__.py", line 16, in 
    from .block import (C1, C2, C3, C3TR, DFL, SPP, SPPF, Bottleneck, BottleneckCSP, C2f, C3Ghost, C3x, GhostBottleneck,
  File "C:\Users\aoqia\Desktop\yolov8-paper\ultralytics\nn\modules\block.py", line 320, in 
    from mmcv.cnn import build_activation_layer, build_norm_layer
ModuleNotFoundError: No module named 'mmcv'

解决办法:我在官网看到用mim命令安装即可。官网地址安装 MMCV — mmcv 2.0.1 文档 。

即采用下面两个步骤:

pip install -U openmim

mim install mmcv

你可能感兴趣的:(YOLOV8,python)