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

安装fastai时出现subprocess.CalledProcessError问题求助

安装fastai时subprocess.CalledProcessError问题解决

问题背景

Python 3.11.8环境(VS Code编辑器)中,执行python -m pip install fastai时触发subprocess.CalledProcessError,错误源于SciPy编译阶段找不到可用编译器,同时提示无法激活VS环境。

完整错误日志

error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [55 lines of output]
      The Meson build system
      Version: 0.62.2
      Source dir: C:\Users\UserPC\AppData\Local\Temp\pip-install-lfh_uajv\scipy_0c2595c1abca45c9840a4fe284f06c6a
      Build dir: C:\Users\UserPC\AppData\Local\Temp\pip-install-lfh_uajv\scipy_0c2595c1abca45c9840a4fe284f06c6a\.mesonpy-qppxu250\build
      Build type: native build
      Project name: SciPy
      Project version: 1.9.1
      WARNING: Failed to activate VS environment: Could not parse vswhere.exe output

      ..\..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']]
      The following exception(s) were encountered:
      Running "icl " gave "[WinError 2] The system cannot find the file specified"
      Running "cl /?" gave "[WinError 2] The system cannot find the file specified"
      Running "cc --version" gave "[WinError 2] The system cannot find the file specified"
      Running "gcc --version" gave "[WinError 2] The system cannot find the file specified"
      Running "clang --version" gave "[WinError 2] The system cannot find the file specified"
      Running "clang-cl /?" gave "[WinError 2] The system cannot find the file specified"
      Running "pgcc --version" gave "[WinError 2] The system cannot find the file specified"

      A full log can be found at C:\Users\UserPC\AppData\Local\Temp\pip-install-lfh_uajv\scipy_0c2595c1abca45c9840a4fe284f06c6a\.mesonpy-qppxu250\build\meson-logs\meson-log.txt
      + meson setup --native-file=C:\Users\UserPC\AppData\Local\Temp\pip-install-lfh_uajv\scipy_0c2595c1abca45c9840a4fe284f06c6a\.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=C:\Users\UserPC\AppData\Local\Programs\Python\Python311 C:\Users\UserPC\AppData\Local\Temp\pip-install-lfh_uajv\scipy_0c2595c1abca45c9840a4fe284f06c6a C:\Users\UserPC\AppData\Local\Temp\pip-install-lfh_uajv\scipy_0c2595c1abca45c9840a4fe284f06c6a\.mesonpy-qppxu250\build
      Traceback (most recent call last):
        File "C:\Users\UserPC\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\UserPC\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\UserPC\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 969, in get_requires_for_build_wheel
          with _project(config_settings) as project:
        File "C:\Users\UserPC\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 948, in _project
          with Project.with_temp_working_dir(
        File "C:\Users\UserPC\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 777, in with_temp_working_dir
          yield cls(source_dir, tmpdir, build_dir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 682, in __init__
          self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 713, in _configure
          self._meson(
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 696, in _meson
          return self._proc('meson', *args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\UserPC\AppData\Local\Temp\pip-build-env-zzmgqcft\overlay\Lib\site-packages\mesonpy\__init__.py", line 691, in _proc
          subprocess.check_call(list(args))
        File "C:\Users\UserPC\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=C:\\Users\\UserPC\\AppData\\Local\\Temp\\pip-install-lfh_uajv\\scipy_0c2595c1abca45c9840a4fe284f06c6a\\.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=C:\\Users\\UserPC\\AppData\\Local\\Programs\\Python\\Python311', 'C:\\Users\\UserPC\\AppData\\Local\\Temp\\pip-install-lfh_uajv\\scipy_0c2595c1abca45c9840a4fe284f06c6a', 'C:\\Users\\UserPC\\AppData\\Local\\Temp\\pip-install-lfh_uajv\\scipy_0c2595c1abca45c9840a4fe284f06c6a\\.mesonpy-qppxu250\\build']' returned non-zero exit status 1.
      [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.

解决方案

  • 安装C++编译工具链:下载并安装Microsoft Visual C++ Build Tools,勾选「Desktop development with C++」组件,确保包含MSVC编译器、Windows SDK等核心工具。安装完成后重启终端再执行安装命令。
  • 使用预编译SciPy包:执行pip install scipy --only-binary :all:,强制使用预编译的wheel包,避免从源码编译。完成后再执行pip install fastai。
  • 降级Python版本:Python 3.11与旧版SciPy(1.9.1)兼容性有限,可降级到Python 3.10版本,再重新安装fastai。
  • 升级Meson构建工具:执行pip install --upgrade meson,旧版Meson可能存在VS环境识别问题,升级后可修复部分编译环境检测异常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 05:22:33