Windows环境下pip安装pandas失败,求助解决C标准相关报错
问题描述
在Windows机器上安装pandas时出现编译报错,执行命令python -m pip install pandas后输出如下错误:
python -m pip install pandas Collecting pandas Using cached pandas-2.2.2.tar.gz (4.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [13 lines of output] + meson setup C:\Users\serba\AppData\Local\Temp\pip-install-6cc_jg_i\pandas_90906587555b4b9d852626b7159094db C:\Users\serba\AppData\Local\Temp\pip-install-6cc_jg_i\pandas_90906587555b4b9d852626b7159094db\.mesonpy-6bapjes7\build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=C:\Users\serba\AppData\Local\Temp\pip-install-6cc_jg_i\pandas_90906587555b4b9d852626b7159094db\.mesonpy-6bapjes7\build\meson-python-native-file.ini The Meson build system Version: 1.2.1 Source dir: C:\Users\serba\AppData\Local\Temp\pip-install-6cc_jg_i\pandas_90906587555b4b9d852626b7159094db Build dir: C:\Users\serba\AppData\Local\Temp\pip-install-6cc_jg_i\pandas_90906587555b4b9d852626b7159094db\.mesonpy-6bapjes7\build Build type: native build Project name: pandas Project version: 2.2.2 Activating VS 15.9.60 ..\..\meson.build:2:0: ERROR: Value "c11" (of type "string") for combo option "C language standard to use" is not one of the choices. Possible choices are (as string): "none", "c89", "c99", "gnu89", "gnu90", "gnu9x", "gnu99". A full log can be found at C:\Users\serba\AppData\Local\Temp\pip-install-6cc_jg_i\pandas_90906587555b4b9d852626b7159094db\.mesonpy-6bapjes7\build\meson-logs\meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
已尝试的解决方法:
- 以管理员身份运行终端
- 更新pip
- 安装pandas旧版本
- 查看报错日志,但进程结束后日志文件已不存在
疑问:是否需要安装特定编译器或其他依赖?
解决方案
错误核心原因
当前使用的Visual Studio 15.9.60(VS2017)版本过旧,自带的C编译器不支持C11标准,而pandas 2.2.x的构建脚本要求使用C11,导致Meson构建工具抛出兼容性错误。
具体解决步骤
使用预编译二进制包(推荐)
跳过源码编译,直接安装pypi提供的预编译wheel包,执行命令:pip install pandas --only-binary :all:该命令强制pip下载适配Windows的预编译包,无需处理编译器兼容问题。
升级Visual Studio版本
安装VS2019及以上版本,安装时必须勾选「使用C的桌面开发」组件,确保C/C编译器、MSBuild等工具完整安装。新版本VS的编译器原生支持C11,可解决标准兼容问题。降级Meson版本
若暂时无法升级VS,可降级Meson到支持旧编译器的版本,执行以下命令:pip uninstall meson -y pip install meson==0.64.0完成后再尝试安装pandas。
匹配Python与pandas版本
若安装旧版pandas仍报错,需确认版本兼容性:- pandas 2.0+要求Python 3.8及以上
- 若使用Python 3.7及以下,安装pandas 1.x系列版本:
pip install pandas==1.5.3
内容的提问来源于stack exchange,提问作者Serban Stoenescu
相关产品推荐
相关产品推荐

