macOS Big Sur下Python3.9安装geopandas失败提示缺少gdal-config
geopandas安装报错记录
执行的安装命令
sudo pip3 install geopandas
依赖拉取阶段正常输出
Collecting geopandas Downloading geopandas-0.8.1-py2.py3-none-any.whl (962 kB) |████████████████████████████████| 962 kB 5.0 MB/s Collecting fiona Downloading Fiona-1.8.18.tar.gz (1.3 MB) |████████████████████████████████| 1.3 MB 4.8 MB/s
中断报错详情
安装流程在编译fiona依赖环节终止,终端返回完整报错信息:
ERROR: Command errored out with exit status 1: command: /usr/local/opt/python@3.9/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"/private/tmp/pip-install-fbu0u179/fiona/setup.py"'; __file__='"/private/tmp/pip-install-fbu0u179/fiona/setup.py"';f=getattr(tokenize, '"open"', open)(__file__);code=f.read().replace('"\n"', '"\n"');f.close();exec(compile(code, __file__, '"exec"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-knmlby9t cwd: /private/tmp/pip-install-fbu0u179/fiona/ Complete output (2 lines): Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config' A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable. ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
报错本质
fiona是geopandas依赖的空间数据读写组件,其编译过程必须调用系统GDAL库提供的gdal-config工具读取版本参数。当前系统未安装GDAL基础库,导致该指令不存在,编译流程无法启动。
解决步骤
- 先完成系统层面GDAL基础库的安装,满足fiona的编译前置要求
- 安装完成后执行
which gdal-config,确认工具已被系统PATH正常识别 - 若安装GDAL后仍存在路径识别问题,可手动设置
GDAL_CONFIG环境变量指向gdal-config的实际存储路径,再重新执行geopandas安装命令
内容的提问来源于stack exchange,提问作者emax
相关产品推荐
相关产品推荐

