安装Pillow、Seaborn时出现Getting requirements to build wheel错误的修复
解决安装Pillow/Seaborn时的SciPy构建wheel错误(缺失Fortran编译器)
错误核心原因:Seaborn依赖SciPy,而编译SciPy的wheel需要Fortran编译器(如gfortran),系统未安装导致Meson构建失败。以下是不同操作系统的解决方法:
Windows系统
- 方案1:直接安装预编译的SciPy包,避免本地编译
pip install scipy --only-binary :all: pip install pillow seaborn - 方案2:安装Fortran编译器
- 下载安装MinGW-w64,确保勾选
gfortran组件 - 将MinGW的
bin目录(例如C:\MinGW\bin)添加到系统环境变量PATH中 - 重新执行安装命令:
pip install pillow seaborn
- 下载安装MinGW-w64,确保勾选
macOS系统
- 安装Xcode命令行工具:
xcode-select --install - 通过Homebrew安装gfortran(包含在gcc包中):
brew install gcc - 执行安装命令:
pip install pillow seaborn
Linux系统
Debian/Ubuntu系列
- 安装编译器及构建依赖:
sudo apt update && sudo apt install gfortran gcc python3-dev - 执行安装命令:
pip install pillow seaborn
RHEL/CentOS/Fedora系列
- 安装编译器及构建依赖:
# Fedora用dnf,CentOS用yum sudo dnf install gcc-gfortran gcc python3-devel - 执行安装命令:
pip install pillow seaborn
替代方案:使用Conda管理环境
如果不想手动处理编译器,可通过Conda自动管理依赖:
- 创建并激活Conda环境:
conda create -n my_env python=3.10 # 可替换为你需要的Python版本 conda activate my_env - 直接安装所需包:
conda install pillow seaborn
内容的提问来源于stack exchange,提问作者田丰尧
相关产品推荐
相关产品推荐

