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

无法用pip下载scipy的wheel包,依赖包下载失败求助

离线Python包下载:Scipy编译失败的解决方法

问题背景

为给离线环境准备Python依赖包,执行以下命令从阿里云镜像下载packages.txt中列出的包到./packs目录:

pip3 download -d ./packs -r packages.txt -i https://mirrors.aliyun.com/pypi/simple/

但Scipy无法生成wheel格式文件,导致依赖它的scikit-learn、statsmodels等包也无法完成下载,核心错误日志如下:

Downloading https://mirrors.aliyun.com/pypi/packages/84/a9/2bf119f3f9cff1f376f924e39cfae18dec92a1514784046d185731301281/scipy-1.10.1.tar.gz (42.4 MB)
     |████████████████████████████████| 42.4 MB 726 kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\liding\appdata\local\programs\python\python38-32\python.exe' 'c:\users\liding\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\liding\AppData\Local\Temp\tmpcp63m4lc'
         cwd: C:\Users\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7
    Complete output (21 lines):
    + meson setup --prefix=c:\users\liding\appdata\local\programs\python\python38-32 C:\Users\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7 C:\Users\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7\.mesonpy-tq02oyez\build --native-file=C:\Users\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7\.mesonpy-native-file.ini -Ddebug=false -Doptimization=2
    The Meson build system
    Version: 1.0.1
    Source dir: C:\Users\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7
    Build dir: C:\Users\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7\.mesonpy-tq02oyez\build
    Build type: native build
    Project name: SciPy
    Project version: 1.10.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\liding\AppData\Local\Temp\pip-download-8bds6eo1\scipy_8794ca23ac8349ecb38e96bac61f61b7\.mesonpy-tq02oyez\build\meson-logs\meson-log.txt
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\liding\appdata\local\programs\python\python38-32\python.exe' 'c:\users\liding\appdata\local\programs\python\python38-32\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\liding\AppData\Local\Temp\tmpcp63m4lc' Check the logs for full command output.

错误原因

Scipy 1.10.1采用Meson构建,需要本地具备C/C++编译器(如MSVC、GCC等),但当前系统既没有安装编译器,也无法激活Visual Studio环境,导致构建工具找不到可用编译器,编译失败。

解决方法

方案1:直接使用预编译wheel包

  • 查找匹配当前环境(Python 3.8 32位、Windows系统)的Scipy预编译.whl文件
  • 将下载好的Scipy wheel放入./packs目录,重新执行原下载命令,pip会优先使用本地已有的wheel,无需再编译

方案2:安装编译环境后重新下载

  • 安装Visual Studio Build Tools,勾选"C++构建工具"组件;或安装MinGW-w64编译器
  • 将编译器路径添加到系统环境变量PATH中(如MSVC的cl.exe路径、MinGW的gcc.exe路径)
  • 重新执行原下载命令,Scipy即可正常编译生成wheel

方案3:降低Scipy版本

  • 修改packages.txt中的Scipy版本为1.7.x及更早版本,这些版本在PyPI上提供预编译wheel,无需本地编译
  • 重新执行下载命令,即可直接获取wheel文件

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 14:44:54