You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac环境安装Unsloth失败求助:Python3.12虚拟环境遇torch依赖问题

Mac上安装Unsloth失败求助

我在Mac上尝试安装Unsloth时遇到了问题:原本我的Python版本是3.13,发现和Unsloth不兼容,于是安装了Python 3.12并创建了专属虚拟环境。但在这个环境里执行pip install unsloth时,出现了如下错误:

Collecting unsloth
  Using cached unsloth-2025.4.7-py3-none-any.whl.metadata (46 kB)
Collecting unsloth_zoo>=2025.4.4 (from unsloth)
  Using cached unsloth_zoo-2025.4.4-py3-none-any.whl.metadata (8.0 kB)
Collecting torch>=2.4.0 (from unsloth)
  Using cached torch-2.7.0-cp312-none-macosx_11_0_arm64.whl.metadata (29 kB)
Collecting xformers>=0.0.27.post2 (from unsloth)
  Using cached xformers-0.0.30.tar.gz (10.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/Users/martinlanius/unsloth_env/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/Users/martinlanius/unsloth_env/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/martinlanius/unsloth_env/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/sh/5xp0lvc57x780mwd65gmq0fh0000gn/T/pip-build-env-istc1kez/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/sh/5xp0lvc57x780mwd65gmq0fh0000gn/T/pip-build-env-istc1kez/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/sh/5xp0lvc57x780mwd65gmq0fh0000gn/T/pip-build-env-istc1kez/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 512, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/sh/5xp0lvc57x780mwd65gmq0fh0000gn/T/pip-build-env-istc1kez/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
        File "<string>", line 24, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

有没有人能帮忙解决这个问题?

内容的提问来源于stack exchange,提问作者Martin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 04:13:09