Search code examples
pythonobject-detectionyolomodulenotfounderroryolov5

YOLO5 : ModuleNotFoundError: No module named 'utils.datasets'


I am running a Yolo5 docker and want to import the train.py file in the yolov5 repository to my code. The structure of my files is as follows:

files structure

when I create the docker image and run main_train.py as follows :

main_train.py:

from yolov5 import train

I get this error message.

Traceback (most recent call last):
File "main_train.py", line 1, in <module>
from yolov5 import train
File "/code/yolov5/train.py", line 40, in <module>
import val  # for end-of-epoch mAP
File "/code/yolov5/val.py", line 37, in <module>
from models.common import DetectMultiBackend
File "/code/yolov5/models/common.py", line 24, in <module>
from utils.dataloaders import exif_transpose, letterbox
ModuleNotFoundError: No module named 'utils.dataloaders'
yolov5-train exited with code 1

Help to fix it.


Solution

  • It just happened to me. It turns out I had a module named utils already installed. Checking where it is with utils.__file__ allowed me to identify where it comes from. Turns out it was installed by the game Endgame: Singularity. Purged the game and it now imports fine.