ModuleNotFoundError: No module named '' while uploading weights

I am trying to upload my YOLOV8 weights to roboflow.

I keep getting this error.

Here is a bit more of the error

loading Roboflow workspace…
loading Roboflow project…
Traceback (most recent call last):
File “/Users/boazburnett/PycharmProjects/Roboflow Testing/”, line 6, in
project.version(3).deploy(model_type=“yolov8”, model_path=“/Users/boazburnett/PycharmProjects/Roboflow Testing/runs/classify/train”)
File “/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/roboflow/core/”, line 478, in deploy
model = torch.load(os.path.join(model_path, “weights/”))
File “/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/torch/”, line 809, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File “/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/torch/”, line 1172, in _load
result = unpickler.load()
File “/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/torch/”, line 1165, in find_class
return super().find_class(mod_name, name)
ModuleNotFoundError: No module named ‘’

And my code

from roboflow import Roboflow
rf = Roboflow(api_key=“secret”)
project = rf.workspace(“boaztheostrich”).project(“cartest-tyaur”)

dataset = project.version(3).download(“yolov8”)

project.version(3).deploy(model_type=“yolov8”, model_path=“/Users/boazburnett/PycharmProjects/Roboflow Testing/runs/classify/train”)


The error you’re encountering seems to be related to the PyTorch library not being able to find the ‘’ module. This issue is not directly related to Roboflow but rather to the dependencies of your YOLOv8 model.

However, to upload your YOLOv8 weights to Roboflow, you can follow these steps:

  1. Ensure that you have the correct version of the Roboflow Python package. You need the roboflow>=1.0.1 Python package version to use the .deploy() command (source).

  2. Make sure your weights are in the correct directory. According to the Roboflow blog, the weights should be in the “/runs/detect/train/weights/” folder of your project.

  3. Use the following code to upload your weights:

from roboflow import Roboflow

rf = Roboflow(api_key="API_KEY")
project = rf.workspace().project("PROJECT_ID")
project.version(DATASET_VERSION).deploy(model_type="yolov8", model_path=f"./runs/detect/train/")

Replace “API_KEY”, “PROJECT_ID”, and “DATASET_VERSION” with your actual API key, project ID, and dataset version respectively.

If you continue to encounter issues, it might be helpful to check the Roboflow documentation or reach out to their support for further assistance.

Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, knowledge base, and previous forum responses. If you find this to be a helpful answer, please mark it as the solution using the checkbox icon below. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.

Hi Lenny,

That didn’t solve my issue you just gave me the code I already had.

I am using roboflow version 1.1.3

Hi @Boaztheostrich ! I’ve seen this error when the version of ultralytics I’m using with the roboflow python package doesn’t match the version of ultralytics I used to train my model.

1 Like

Hi @Paul thanks for the response! I think that was the solution however I am now getting an error code talking about nc?

It relates to this code within

    if "yolov8" in model_type:
        # try except for backwards compatibility with older versions of ultralytics
        if "-cls" in model_type:
            nc = model["model"].yaml["nc"]
            args = model["train_args"]
            nc = model["model"].nc
            args = model["model"].args
            model_artifacts = {
                "names": class_names,
                "yaml": model["model"].yaml,
                "nc": nc,
                "args": {
                    k: val
                    for k, val in args.items()
                    if ((k == "model") or (k == "imgsz") or (k == "batch"))
                "ultralytics_version": ultralytics.__version__,
                "model_type": model_type,

When I changed the model name to “yolov8-cls” it did successfully upload however all of my predictions were at 0% MAP etc.

Any help would be appreciated