直接安装报错如下,安装完C++生成工具后依然无法安装GDAL
pip install GDAL
Collecting GDAL
Using cached GDAL-3.8.5.tar.gz (802 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: GDAL
Building wheel for GDAL (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for GDAL (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [135 lines of output]
WARNING: numpy not available! Array support will not be enabled
running bdist_wheel
running build
running build_py
creating build
/Tpextensions/osr_wrap.cpp /Fobuild\temp.win-amd64-cpython-312\Release\extensions/osr_wrap.obj
gnm_wrap.cpp
gdal_wrap.cpp
extensions/gdalconst_wrap.c(3013): fatal error C1083: 无法打开包括文件: “gdal.h”: No such file or directory
ogr_wrap.cpp
osr_wrap.cpp
extensions/gnm_wrap.cpp(3153): fatal error C1083: 无法打开包括文件: “gdal.h”: No such file or directory
extensions/gdal_wrap.cpp(3222): fatal error C1083: 无法打开包括文件: “cpl_port.h”: No such file or directory
extensions/osr_wrap.cpp(3213): fatal error C1083: 无法打开包括文件: “cpl_string.h”: No such file or directory
extensions/ogr_wrap.cpp(3181): fatal error C1083: 无法打开包括文件: “gdal.h”: No such file or directory
error: command failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for GDAL
Failed to build GDAL
ERROR: Could not build wheels for GDAL, which is required to install pyproject.toml-based projects
安装
找了教程,但是下载地址已经失效。
Windows
可以在下面的链接进行下载
GDAL下载地址
下载对应python版本的 whl 格式的安装包,然后使用命令安装即可
pip install 下载文件名
pip install GDAL-3.8.4-cp312-cp312-win_amd64.whl