Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix an import error (#1767)

Nino Risteski1b329a6731b3
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 39b367e2752..186545cf0ce 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -24,10 +24,14 @@ from peft import PeftConfig, PeftModel
from .loader_utils import get_model_name
import os, contextlib, sys
try:
- from huggingface_hub.utils import get_token
+ from huggingface_hub import get_token
except:
- # Old HF Hub versions <= 0.0.25
- from huggingface_hub.utils._token import get_token
+ try:
+ from huggingface_hub.utils import get_token
+ except:
+ # For older versions of huggingface_hub
+ from huggingface_hub.utils._token import get_token
+ pass
pass
from huggingface_hub import HfFileSystem
import importlib.util
diff --git a/unsloth/save.py b/unsloth/save.py
index 0f75ecfd054..eaddfa05c53 100644
--- a/unsloth/save.py
+++ b/unsloth/save.py
@@ -31,10 +31,14 @@ from transformers.models.llama.modeling_llama import logger
from .tokenizer_utils import fix_sentencepiece_gguf
from huggingface_hub import HfApi
try:
- from huggingface_hub.utils import get_token
+ from huggingface_hub import get_token
except:
- # Old HF Hub versions <= 0.0.25
- from huggingface_hub.utils._token import get_token
+ try:
+ from huggingface_hub.utils import get_token
+ except:
+ # For older versions of huggingface_hub
+ from huggingface_hub.utils._token import get_token
+ pass
pass
from pathlib import Path