GDAL安装错误“错误:命令'x86_64-linux-gnu-gcc'失败,退出状态为1”

时间:2019-04-26 00:22:04

标签: python gdal

我正在尝试使用python安装GDAL,但是由于错误而失败。

我使用的命令是pip install GDAL

  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o -std=c++11 -I/usr/include/gdal
  extensions/gdal_wrap.cpp:3177:27: fatal error: cpl_vsi_error.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


  ----------------------------------------
  Failed building wheel for GDAL
  Running setup.py clean for GDAL
Failed to build GDAL
Installing collected packages: GDAL
  Running setup.py install for GDAL ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_spRXy/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-NxpUaO-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying gdal.py -> build/lib.linux-x86_64-2.7
    ...
    creating build/temp.linux-x86_64-2.7/extensions
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o -std=c++11 -I/usr/include/gdal
    extensions/gdal_wrap.cpp:3177:27: fatal error: cpl_vsi_error.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_spRXy/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-NxpUaO-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_spRXy/GDAL/

我已经尝试过sudo apt-get install build-essential,但仍会出现相同的错误。

1 个答案:

答案 0 :(得分:0)

这是我发现可行的答案:

“您可能必须将gdal版本更改为主机上安装的版本。所以我必须这样做,因为我主机上的gdal == 1.11.2:”

pip install gdal==1.11.2 --global-option=build_ext --global-option="-I/usr/include/gdal/"

应将1.11.2更新到您的gdal_version,该文件可以在# define GDAL_RELEASE_NAME文件的行/usr/include/gdal/gdal_version.h中找到(至少在运行Kubuntu的系统上)。

使用Basaks的答案链接到原始github page,上面的评论由Craicerjack提到。