我可以使用 pip 在我的 mac 上为 python2.7 pip 安装 GDAL。但是,当我尝试使用 python3.6 安装软件包时 pip3 install gdal 我收到一条很长的错误消息,以此结尾:
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
extensions/gdal_wrap.cpp:3168:10: fatal error: 'cpl_port.h' file not found
#include "cpl_port.h"
^~~~~~~~~~~~
1 warning and 1 error generated.
error: command 'clang' failed with exit status 1
我尝试按照此处的建议使用自制软件重新安装 GDAL,Unable to install GDAL in python 3 using pip (clang failed with exit status 1) ,但没有运气。寻找任何建议。
请您参考如下方法:
我尝试了很多使用 PIP 安装 GDAL 包的方法,但最终要么丢失了一些模块,要么遇到了错误。因此,安装 GDAL 的最佳解决方案是设置 condo 环境并安装可以工作的 gdal:
conda create --name yourenvnamehere python=python3.7
conda activate yourenvnamehere
conda install -c anaconda numpy
conda install -c conda-forge gdal
如果你遵循了上面的代码:
导入gdal
应该可以。使用空间数据快乐编码:)
