Skip to content

Fix compatibility with setuptools ≥ 82 and PyTorch ≥ 2.6#264

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-issue-with-yolov5-pip
Draft

Fix compatibility with setuptools ≥ 82 and PyTorch ≥ 2.6#264
Copilot wants to merge 3 commits intomainfrom
copilot/fix-issue-with-yolov5-pip

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 20, 2026

Two upstream breaking changes rendered the package non-functional: pkg_resources was removed from setuptools in v82, and PyTorch 2.6 flipped torch.load's weights_only default from False to True.

Changes

  • pkg_resourcespackaging.version (yolov5/utils/general.py, yolov5/utils/loggers/__init__.py)

    # Before
    import pkg_resources as pkg
    pkg.parse_version(x)
    
    # After
    from packaging.version import parse as parse_version
    parse_version(x)

    Added packaging>=21.0 to requirements.txt.

  • torch.load weights_only — added weights_only=False to all 7 call sites across 5 files (models/experimental.py, train.py, hubconf.py, utils/general.py, segment/train.py). YOLOv5 checkpoints contain custom Python globals (models.yolo.Model) that are incompatible with weights_only=True.

    # Before
    ckpt = torch.load(weights, map_location='cpu')
    
    # After
    ckpt = torch.load(weights, map_location='cpu', weights_only=False)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dns.google
    • Triggering command: /usr/bin/python python -c import yolov5.utils.general (dns block)
    • Triggering command: /usr/bin/python python -m unittest (dns block)
    • Triggering command: /usr/bin/python python -m unittest tests.test_yolov5.TestYolov5FromUltralytics (dns block)
  • https://api.github.com/repos/ultralytics/yolov5/releases/latest
    • Triggering command: /usr/bin/python python -m unittest (http block)
    • Triggering command: /usr/bin/python python -m unittest tests.test_yolov5.TestYolov5FromUltralytics (http block)
  • https://api.github.com/repos/ultralytics/yolov5/releases/tags/v7.0
    • Triggering command: /usr/bin/python python -m unittest (http block)
    • Triggering command: /usr/bin/python python -m unittest tests.test_yolov5.TestYolov5FromUltralytics (http block)
  • huggingface.co
    • Triggering command: /usr/bin/python python -m unittest (dns block)
  • one.one.one.one
    • Triggering command: /usr/bin/python python -c import yolov5.utils.general (dns block)
    • Triggering command: /usr/bin/python python -m unittest (dns block)
    • Triggering command: /usr/bin/python python -m unittest tests.test_yolov5.TestYolov5FromUltralytics (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…ls>=82

Co-authored-by: fcakyon <34196005+fcakyon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with YOLOv5 installation instructions Replace pkg_resources with packaging.version Mar 20, 2026
Copilot AI requested a review from fcakyon March 20, 2026 17:13
Copilot AI changed the title Replace pkg_resources with packaging.version Fix compatibility with setuptools ≥ 82 and PyTorch ≥ 2.6 Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants