gpt4 book ai didi

docker - Alpine 编译失败中的 Gdal 安装 - "error: command ' gcc' 失败,退出状态为 1"

转载 作者:行者123 更新时间:2023-12-01 00:14:58 25 4
gpt4 key购买 nike

我正在尝试在 Alpine docker env 中安装 Gdal。我安装了 Gdal 的依赖项,一切正常

RUN apk add --no-cache gcc build-base /gdal/gdal-dev-2.4.0-r1.apk /gdal/gdal-2.4.0-r1.apk /gdal/geos-3.7.1-r0.apk /gdal/libcrypto1.1-1.1.1b-r1.apk

然后我运行命令 "pip install gdal"它下载 GDAL-3.0.0.tar.gz 但在安装时出现错误。

修剪过的原木;

Building wheels for collected packages: gdal
Building wheel for gdal (setup.py) ... error
ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-hlldvrpz/gdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-dj2y5pji --python-tag cp37:
ERROR: WARNING: numpy not available! Array support will not be enabled
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
copying gdal.py -> build/lib.linux-x86_64-3.7
copying ogr.py -> build/lib.linux-x86_64-3.7
...
...
...
running build_ext
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/local/include/python3.7m -I. -I/usr/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
building 'osgeo._gdal' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/extensions
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/local/include/python3.7m -I. -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.7/extensions/gdal_wrap.o -I/usr/include
extensions/gdal_wrap.cpp: In function 'OSRSpatialReferenceShadow* GDALDatasetShadow_GetSpatialRef(GDALDatasetShadow*)':
extensions/gdal_wrap.cpp:4672:54: error: 'GDALGetSpatialRef' was not declared in this scope
OGRSpatialReferenceH ref = GDALGetSpatialRef(self);
^
extensions/gdal_wrap.cpp: In function 'void GDALDatasetShadow_SetSpatialRef(GDALDatasetShadow*, OSRSpatialReferenceShadow*)':
extensions/gdal_wrap.cpp:4681:57: error: 'GDALSetSpatialRef' was not declared in this scope
GDALSetSpatialRef( self, (OGRSpatialReferenceH)srs );
...
...
In file included from /usr/local/include/python3.7m/Python.h:147:0,
from extensions/gdal_wrap.cpp:173:
/usr/local/include/python3.7m/abstract.h:489:17: note: declared here
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
^~~~~~~~~~~~~~~~~~~~~
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for gdal
Running setup.py clean for gdal
...
...
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-hlldvrpz/gdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-fapa0jlw/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-hlldvrpz/gdal/

最佳答案

似乎存在GDAL版本冲突:

  • pip install gdal 提取 GDAL 3.0.0 的源代码压缩包并尝试从源代码构建它;
  • 正在安装 2.4.0-r1 gdal-dev 软件包,这确实是 Alpine repositories 中提供的最新版本;
  • GDAL 3.0.0 不会针对 2.4.0-r1 gdal-dev header 构建。

作为一种解决方法,安装匹配版本 2.4.0 的 GDAL 模块可能会成功:

pip install 'gdal==2.4.0'

关于docker - Alpine 编译失败中的 Gdal 安装 - "error: command ' gcc' 失败,退出状态为 1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56099491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com