GDAL安装失败指引

mac os 14.4.1
pip install gdal
报错 subprocess-exited-with-error
详细报错间本文底部。

处理方法

缺少 gdal-config 文件(GDAL 的必需文件)你需要先安装 GDAL 的依赖库。

macOS

可以使用 Homebrew 来安装 GDAL:

```sh
brew install gdal
```

Linux

可以使用系统的包管理工具来安装 GDAL。比如在 Ubuntu 上,你可以运行:

```sh
sudo apt-get install gdal-bin libgdal-dev
```

Windows下

可以下载 GDAL 的预编译版本并进行安装。你可以从 [GIS Internals](http://www.gisinternals.com/release.php) 下载适合你的版本。下载并安装后,需要将 GDAL 的 `bin` 目录添加到你的系统 `PATH` 环境变量中。

安装完成后,尝试重新安装 Python 的 GDAL 包:

pip install gdal

结果

在这里插入图片描述

详细报错信息

Collecting gdal
Using cached GDAL-3.9.0.tar.gz (839 kB)
Installing build dependencies … done
Getting requirements to build wheel … error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit
code: 1 ╰─> [86 lines of output] Using numpy 2.0.0rc2 running egg_info
writing gdal-utils/GDAL.egg-info/PKG-INFO writing dependency_links to
gdal-utils/GDAL.egg-info/dependency_links.txt writing entry points to
gdal-utils/GDAL.egg-info/entry_points.txt writing requirements to
gdal-utils/GDAL.egg-info/requires.txt writing top-level names to
gdal-utils/GDAL.egg-info/top_level.txt Traceback (most recent call
last): File “”, line 91, in fetch_config File
“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,
line 947, in init self._execute_child(args, executable, preexec_fn,
close_fds, File
“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,
line 1819, in _execute_child raise child_exception_type(errno_num,
err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or
directory: ‘gdal-config’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “”, line 231, in
get_gdal_config File “”, line 94, in fetch_config
main.gdal_config_error: [Errno 2] No such file or directory: ‘gdal-config’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File
“/Users/moscato/PycharmProjects/paintColorBar/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”,
line 353, in
main() File “/Users/moscato/PycharmProjects/paintColorBar/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”,
line 335, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’]) File “/Users/moscato/PycharmProjects/paintColorBar/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”,
line 118, in get_requires_for_build_wheel
return hook(config_settings) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/build_meta.py”,
line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[‘wheel’]) File
“/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/build_meta.py”,
line 295, in _get_build_requires
self.run_setup() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/build_meta.py”,
line 311, in run_setup
exec(code, locals()) File “”, line 421, in File
“/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/init.py”, line 103, in setup
return distutils.core.setup(**attrs) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py”,
line 184, in setup
return run_commands(dist) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py”,
line 200, in run_commands
dist.run_commands() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py”,
line 969, in run_commands
self.run_command(cmd) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/dist.py”, line 968, in run_command
super().run_command(command) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py”,
line 988, in run_command
cmd_obj.run() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py”,
line 321, in run
self.find_sources() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py”,
line 329, in find_sources
mm.run() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py”,
line 550, in run
self.add_defaults() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py”,
line 588, in add_defaults
sdist.add_defaults(self) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/command/sdist.py”,
line 102, in add_defaults
super().add_defaults() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py”,
line 250, in add_defaults
self._add_defaults_ext() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py”,
line 334, in _add_defaults_ext
build_ext = self.get_finalized_command(‘build_ext’) File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py”,
line 303, in get_finalized_command
cmd_obj.ensure_finalized() File “/private/var/folders/67/9st2zynd7z98393n0w9dfhxh0000gn/T/pip-build-env-_fb32qe4/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py”,
line 111, in ensure_finalized
self.finalize_options() File “”, line 307, in finalize_options File “”, line 237, in get_gdal_config
main.gdal_config_error: Traceback (most recent call last): File “”, line 91, in fetch_config File
“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,
line 947, in init
self._execute_child(args, executable, preexec_fn, close_fds, File
“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,
line 1819, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: ‘gdal-config’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “”, line 231, in
get_gdal_config File “”, line 94, in fetch_config
gdal_config_error: [Errno 2] No such file or directory: ‘gdal-config’
Could not find gdal-config. Make sure you have installed the GDAL native library and development headers. [end of output] note: This
error originates from a subprocess, and is likely not a problem with
pip. error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit
code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a
problem with pip.

  • 8
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值