GDAL (CentOS 8) 安装失败

GDAL (CentOS 8) Install Failing

今天大部分时间,我一直在努力思考如何在我的 CentOS 8 服务器上安装 GDAL。

我在不同站点和 Whosebug 上研究了许多不同的答案和解决方案,但似乎没有任何效果! (我可能在某处遗漏了一些明显的东西)

我正在尝试使用命令 pip3 install gdal

安装 GDAL

在 return 中产生以下错误:

    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.6 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ydh0zt_x/gdal_e96fd73bd85b4e338f6c0fb234dcfaf1/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ydh0zt_x/gdal_e96fd73bd85b4e338f6c0fb234dcfaf1/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-wx20mgo0/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/gdal
         cwd: /tmp/pip-install-ydh0zt_x/gdal_e96fd73bd85b4e338f6c0fb234dcfaf1/
    Complete output (28 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    copying gdal.py -> build/lib.linux-x86_64-3.6
    copying ogr.py -> build/lib.linux-x86_64-3.6
    copying osr.py -> build/lib.linux-x86_64-3.6
    copying gdalconst.py -> build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/__init__.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdal.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdal_array.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdalconst.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/ogr.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/osr.py -> build/lib.linux-x86_64-3.6/osgeo
    running build_ext
    Could not run gdal-config!!!!
    building 'osgeo._gdal' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/extensions
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/include/python3.6m -I. -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.6/extensions/gdal_wrap.o
    extensions/gdal_wrap.cpp:2813:10: fatal error: cpl_port.h: No such file or directory
     #include "cpl_port.h"
              ^~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.6 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ydh0zt_x/gdal_e96fd73bd85b4e338f6c0fb234dcfaf1/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ydh0zt_x/gdal_e96fd73bd85b4e338f6c0fb234dcfaf1/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-wx20mgo0/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/gdal Check the logs for full command output.

到目前为止,我已经安装了:

我在上面的输出中发现的错误是 cpl_port.h: No such file or directory 我已经在其他论坛上交叉检查了这个错误,他们建议 运行 使用以下命令:

sudo apt-get install libgdal-dev

export CPLUS_INCLUDE_PATH=/usr/include/gdal

export C_INCLUDE_PATH=/usr/include/gdal

最后,运行执行 pip3 install gdal 命令。

虽然,因为我是 运行ning CentOS 8,所以我无法访问 "apt-get" 而是尝试使用 "Yum" 但没有任何运气让上述建议的解决方案起作用。

有人可以建议或推荐任何解决 CentOS 8 服务器上 cpl_port.h: No such file or directory 错误的方法吗?

非常感谢! :-)

这似乎是 CentOS 的一个错误 https://bugs.centos.org/view.php?id=18213

gdal 需要 poppler-0.67,官方存储库中缺少它。 但是它存在于 raven-extras 仓库中: https://centos.pkgs.org/8/raven-extras-x86_64/poppler-0.67.0-22.el8.x86_64.rpm.html

或者你可以原样下载(这里任意命名为poppler0.67.rpm)安装时使用gdal

curl -o poppler0.67.rpm https://pkgs.dyn.su/el8/extras/x86_64/poppler-0.67.0-22.el8.x86_64.rpm
yum install -y gdal poppler0.67.rpm

更新:错误似乎已解决https://bugzilla.redhat.com/show_bug.cgi?id=1950024