Search code examples
pythonpython-3.6yolov8nvidia-jetsonultralytics

Run Yolov8 for Python 3.6


Yolov8 is build to run with 3.8 or above and pip install ultralytics is not compatible with prior versions.

I have the constraint of using a prior version of Python to execute the code on a microcomputer like Jetson Nano or Jetson Xavier.

I've seen on many issues of Yolov8 repository people asking how to solve this issue aswell.

I'll answer bellow, the solution I have found so that others can benefit it or improve it.


Solution

  • First start by cloning the ultralytics repository git clone https://github.com/ultralytics/ultralytics.git into your lib folder.

    Then do the following modifications:

    1. In "[your_path]/lib/ultralytics/ultralytics/utils/__init__.py"
    • Comment import importlib.metadata line 4 replace it by import pkg_resources
    • Replace importlib.metadata.version("torchvision") by TORCHVISION_VERSION = pkg_resources.get_distribution("torchvision").version line 47

    This is because importlib.metadata is not present in python 3.6

    1. In "[your_path]/lib/ultralytics/ultralytics/utils/checks.py",
    • Comment import importlib.metadata line 13
    1. in “[your_path]/lib/ultralytics/ultralytics/hub/auth.py”
    • replace if header := self.get_auth_header(): line 93 by

    header = self.get_auth_header() if header:

    This is because the walrus operator is not present in python 3.6

    WARNING

    This might break some things in the way yolov8 is working. But from what I have tested it is sufficient to run the predictions.