Open michael-mayo opened 4 days ago
π Hello @michael-mayo, thank you for reaching out and for your interest in YOLOv5 π! This is an automated response to let you know that an Ultralytics engineer will assist you soon.
It looks like you're encountering a ModuleNotFoundError
in your Python 3.12 environment when trying to train YOLOv5. For π Bug Reports like this one, it's crucial to have a clear minimum reproducible example to diagnose the issue accurately, which you have provided.
Meanwhile, you might want to consider:
Ensuring all dependencies specified in requirements.txt
are installed. You can do this with pip install -r requirements.txt
.
Verifying your Python environment has all necessary packages for YOLOv5, including huggingface_hub
, as indicated by your error message. Installing missing modules with pip install huggingface_hub
may help.
Checking compatibility with your specific setup, as some modules might have different support depending on the Python version.
For custom training β Questions, providing additional context such as specific dataset details and any relevant logs can be beneficial. Also, make sure you're following our best practices for optimal training results.
If you're looking for additional guidance on setups or training environments, consider using our verified environments like Notebooks, Google Cloud, or Docker, which offer dependencies pre-installed.
Stay tuned for further assistance from our team! π
Following the bot's suggestion I added pip install huggingface_hub
to the above reproducible example which fails to resolve the issue. Calling python train.py --epochs 1
from inside the yolov5 docker image or from a github clone of the repo does work OK however, so I think the issue is that the version on pypi needs to be updated.
@michael-mayo thanks for the update. It seems like the PyPI package might be outdated. Please try cloning the latest version from GitHub directly, as it should resolve the issue. If the problem persists, let us know.
@michael-mayo thanks for the update. It seems like the PyPI package might be outdated. Please try cloning the latest version from GitHub directly, as it should resolve the issue. If the problem persists, let us know.
Yes that works, but in a production environment I cannot rely on having git available. I currently need to install everything using pip. There is a way to install the latest commit directly via pip using the command pip install git+https://github.com/ultralytics/yolov5.git
but this also fails with a different error:
pip install git+https://github.com/ultralytics/yolov5.git
Collecting git+https://github.com/ultralytics/yolov5.git
Cloning https://github.com/ultralytics/yolov5.git to /tmp/pip-req-build-akqy6tao
Running command git clone --filter=blob:none --quiet https://github.com/ultralytics/yolov5.git /tmp/pip-req-build-akqy6tao
Resolved https://github.com/ultralytics/yolov5.git to commit 2f74455adc74a587c9e9d5a6e45df880fce8ea3e
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
Γ Getting requirements to build wheel did not run successfully.
β exit code: 1
β°β> [14 lines of output]
error: Multiple top-level packages discovered in a flat-layout: ['data', 'models', 'segment', 'classify'].
To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.
If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:
1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names
To find more information, look for "package discovery" on setuptools docs.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
Γ Getting requirements to build wheel did not run successfully.
β exit code: 1
β°β> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I have not been able to find a fix for this yet, so if you have one, that would be great. Otherwise an updated pypi release would be much appreciated.
To resolve the installation issue via pip, try using the following command to install directly from the GitHub repo:
pip install git+https://github.com/ultralytics/yolov5.git#egg=yolov5
If this doesn't work, please consider using a stable release from GitHub until the PyPI package is updated. We appreciate your patience.
pip install git+https://github.com/ultralytics/yolov5.git#egg=yolov5
That command also does not work with the same error. Does it work at your end?
Please ensure you have the latest version of setuptools
and wheel
installed with pip install --upgrade setuptools wheel
, then try the command again. If the issue persists, using a GitHub clone is recommended until the PyPI package is updated.
@pderrenger I can also replicate these issues. To be able to install from the git repo, my understanding is that you will need to update your pyproject.toml
e.g. see https://stackoverflow.com/questions/72294299/multiple-top-level-packages-discovered-in-a-flat-layout.
@michael-mayo My current workaround is to pin huggingface-hub<0.25.0
. I don't know if this will be possible for you though.
Thank you for the suggestion. We'll look into updating the pyproject.toml
to address this. Meanwhile, pinning huggingface-hub<0.25.0
is a helpful workaround. If you have further issues, please ensure you're using the latest version from GitHub.
Search before asking
YOLOv5 Component
Training, Detection
Bug
Environment
Minimal Reproducible Example
Additional
The errror occurs both when training a model and also when trying to load a custom local model using
torch.hub.load
. Error also occurs when running directly on windows, and when I downgrade Pytorch to 2.4. It appears to be caused by the pypi version of yolov5 referencing hugging face modules that no longer exist.Are you willing to submit a PR?