如何在Jupyter Notebook中安装GeoPandas?已试常用方案均报错
解决Windows Anaconda base环境安装GeoPandas报错方案
前置校验
- 打开Anaconda Prompt,依次执行以下命令,确认环境指向正确:
- 确认Python版本:
python --version,输出应为3.9.6 - 确认Python路径:
where python,输出路径匹配你的Anaconda base环境安装路径 - 确认pip绑定:
pip --version,显示关联的Python版本为3.9.6
- 确认Python版本:
清理残留安装内容
执行以下命令删除异常残留的GeoPandas及其核心依赖、清理conda缓存:
pip uninstall -y geopandas fiona pyproj shapely rtree conda clean --all -y
按顺序安装依赖与主包
GeoPandas安装失败90%由核心依赖版本不兼容导致,不要直接安装主包,先单独安装四个核心依赖:
conda install -c conda-forge fiona pyproj shapely rtree -y
依赖安装无报错后,再安装GeoPandas主包:
conda install -c conda-forge geopandas -y
若安装过程提示依赖冲突,可先执行
conda update --all -c conda-forge -y将base环境所有包升级为conda-forge源的兼容版本后,再重复上述安装步骤
备选预编译包安装方案
如果conda源网络异常导致安装失败,直接使用国内镜像站的预编译whl包安装:
pip install geopandas -i https://pypi.tuna.tsinghua.edu.cn/simple --only-binary :all:
安装验证
关闭当前Anaconda Prompt,重新打开新窗口执行验证命令:
python -c "import geopandas; print(geopandas.__version__)"
正常输出版本号即代表安装成功。
内容的提问来源于stack exchange,提问作者dingaro
相关产品推荐
相关产品推荐

