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.

Update import_fixes.py

Daniel Hanc74d5e4ed6c9
diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py
index 1577a8384e2..09c86379922 100644
--- a/unsloth/import_fixes.py
+++ b/unsloth/import_fixes.py
@@ -115,8 +115,11 @@ def fix_xformers_performance_issue():
return
xformers_version = importlib_version("xformers")
if Version(xformers_version) < Version("0.0.29"):
- xformers_location = importlib.util.find_spec("xformers").origin
- xformers_location = os.path.split(xformers_location)[0]
+ xformers_location = importlib.util.find_spec("xformers")
+ if xformers_location is None:
+ xformers_location = importlib.util.find_spec("xformers").submodule_search_locations[0]
+ else:
+ xformers_location = os.path.split(xformers_location.origin)[0]
cutlass = Path(xformers_location) / "ops" / "fmha" / "cutlass.py"
try:
if cutlass.exists():
@@ -144,8 +147,11 @@ def fix_vllm_aimv2_issue():
return
vllm_version = importlib_version("vllm")
if Version(vllm_version) < Version("0.10.1"):
- vllm_version = importlib.util.find_spec("vllm").origin
- vllm_version = os.path.split(vllm_version)[0]
+ vllm_version = importlib.util.find_spec("vllm")
+ if vllm_version is None:
+ vllm_version = importlib.util.find_spec("vllm").submodule_search_locations[0]
+ else:
+ vllm_version = os.path.split(vllm_version.origin)[0]
ovis_config = Path(vllm_version) / "transformers_utils" / "configs" / "ovis.py"
try:
if ovis_config.exists():
@@ -388,8 +394,11 @@ def torchvision_compatibility_check():
def fix_openenv_no_vllm():
if importlib.util.find_spec("trl") is None:
return
- trl_location = importlib.util.find_spec("trl").origin
- trl_location = os.path.split(trl_location)[0]
+ trl_location = importlib.util.find_spec("trl")
+ if trl_location is None:
+ trl_location = importlib.util.find_spec("trl").submodule_search_locations[0]
+ else:
+ trl_location = os.path.split(trl_location.origin)[0]
openenv = Path(trl_location) / "experimental" / "openenv" / "utils.py"
if not openenv.exists():
return
@@ -428,11 +437,11 @@ def fix_openenv_no_vllm():
def fix_executorch():
if importlib.util.find_spec("executorch") is None:
return
- executorch_location = importlib.util.find_spec("executorch").origin
+ executorch_location = importlib.util.find_spec("executorch")
if executorch_location is None:
executorch_location = importlib.util.find_spec("executorch").submodule_search_locations[0]
else:
- executorch_location = os.path.split(executorch_location)[0]
+ executorch_location = os.path.split(executorch_location.origin)[0]
executorch = Path(executorch_location) / "examples" / "models" / "__init__.py"
if not executorch.exists():
return