From 1ddcee387eff3f746d8de5e2126e14bc41c327c3 Mon Sep 17 00:00:00 2001 From: naliazheli Date: Sat, 22 Mar 2025 08:44:25 +0800 Subject: [PATCH] fix(utils): add missing importlib import to fix NameError (#2134) This commit fixes a NameError that occurs when `importlib` is referenced in _utils.py without being imported, especially when UNSLOTH_USE_MODELSCOPE=1 is enabled. By adding the missing import statement, the code will no longer throw a NameError. --- unsloth/models/_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 6a96e8d1f5..0044c7e761 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -1243,6 +1243,7 @@ for j, function in enumerate(functions): except: continue pass +import importlib USE_MODELSCOPE = os.environ.get("UNSLOTH_USE_MODELSCOPE", "0") == "1" if USE_MODELSCOPE: if importlib.util.find_spec("modelscope") is None: