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

安装pyproject.toml项目时pandas wheel构建失败求助

解决Windows 10下pip安装pandas==1.2.0时cl.exe编译失败的问题

问题描述

  • 运行环境:Windows 10,Python 3.11,pip 23.2.1
  • 问题:单独执行pip install pandas可正常安装2.0.3版本,但安装requirements.txt时,因指定pandas==1.2.0,构建wheel过程触发编译错误:
    command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe' failed with exit code 2
    
  • 已尝试无效操作:更换Python 3.10、手动下载不匹配的pandas-1.4.3 wheel、手动添加cl.exe路径

解决方案

1. 安装匹配版本的预编译pandas wheel

pandas 1.2.0发布时Python 3.11还未推出,官方没有提供对应预编译包,pip只能源码编译导致报错。你需要下载与Python版本、系统位数完全匹配的pandas 1.2.0第三方预编译wheel:

  • 先确认Python位数:执行python -c "import sys; print(sys.maxsize > 2**32)",True为64位,False为32位
  • 下载对应wheel(比如Python 3.10 64位就找pandas-1.2.0-cp310-cp310-win_amd64.whl)
  • 本地安装:pip install 你的wheel文件路径\pandas-1.2.0-cpXXX-cpXXX-winXXX.whl

2. 配置兼容的VC++编译环境(源码编译用)

cl.exe报错本质是编译环境不兼容,pandas 1.2.0对新版本MSVC支持不佳,需调整环境:

  • 打开Visual Studio Installer,勾选**"Desktop development with C++"**工作负载,额外选择:
    • MSVC v142 - VS 2019 C++ x64/x86 build tools(1.2.0编译适配该版本)
    • 对应Windows 10 SDK版本
  • 安装完成后,打开**"x64 Native Tools Command Prompt for VS 2019"**(64位Python),在该终端内执行pip install -r requirements.txt

3. 放宽pandas版本要求(折中方案)

如果业务允许,可将requirements.txt中的pandas==1.2.0改为pandas>=1.4.4(1.4.4是首个支持Python 3.11的pandas版本),直接安装预编译包跳过编译步骤

4. 用虚拟环境隔离依赖

全局环境可能存在依赖冲突,创建干净虚拟环境重试:

python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 04:35:19