【问题标题】:Error while installing GDAL安装GDAL时出错
【发布时间】:2016-07-28 08:04:09
【问题描述】:

我正在尝试通过 pip 安装 GDAL。但我收到了这个错误:

extensions/gdal_wrap.cpp:3089:27: fatal error: cpl_vsi_error.h: No such     file or directory
 #include "cpl_vsi_error.h"
                           ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

我使用了这些命令:

sudo apt-get install libgdal-dev
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL

谁能告诉我怎么安装?

【问题讨论】:

标签: python pip gdal


【解决方案1】:

检查您是否使用此命令安装了 GDAL

gdal-config --version

然后运行以下命令:

pip download="some_path" GDAL
cd some_path
tar -xvzf GDAL-<version>.tar.gz
cd GDAL-<version>
python setup.py build_ext --include-dirs=/usr/include/gdal/
python setup.py install

【讨论】:

  • 对于其他卡住的人,根据您安装 GDAL 的方式,丢失的头文件可能有不同的位置。我通过 kyngchaos 安装,对我来说正确的路径是:--include-dirs=/Library/Frameworks/GDAL.framework/Versions/2.1/Headers/
  • pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')
  • pip3 download "$HOME/Downloads/" GDAL ERROR: Directory '/home/leonardo/Downloads/' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
  • 我被指示将“core”和“python bindings”二进制文件下载到我的计算机上。这些都是我需要下载的吗?这样做后,命令gdal-config --version 会产生一个错误,指出根据我的问题over here,它不被识别为命令
【解决方案2】:

在我的 MacBook 上,使用 this 方法和 homebrew 更新/全新安装 GDAL 效果很好。我的 Mac 上的问题是我显然安装了旧的 GDAL 版本,并且由于上述错误消息而无法使用 brew upgrade gdal 进行更新。

简而言之:

brew unlink gdal
brew tap osgeo/osgeo4mac && brew tap --repair
brew install jasper netcdf # gdal dependencies
brew install gdal2 --with-armadillo --with-complete --with-libkml --with-unsupported
brew link --force gdal2

验证:

$> gdal-config --version
2.1.3
$> gdal-config --libs
-L/usr/local/Cellar/gdal2/2.1.3_3/lib -lgdal
$> gdal-config --cflags
-I/usr/local/Cellar/gdal2/2.1.3_3/include

【讨论】:

  • 不得不混合上述一些答案,但让它在我运行 el capitan 的 Mac 上工作!在使用 felice 的 brew 答案安装之前,我必须运行 export C_INCLUDE_PATH=/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7/ 在 brew 安装之后,我必须运行:pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')
  • 你需要先做上面的“解决方案”,然后做“验证”,最后做pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}') by imapotatoe123。
  • 使用来自@imapotatoe123 的修复程序
  • 每次我在这里读到awk -F,在我的脑海里读起来都像F*一样尴尬。 :D
【解决方案3】:
pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')

这是nicerobot 对this comment 的复制粘贴,目前获得的赞成票比所有当前发布的答案加起来还要多。

据我所知,它要求 pip 安装与已安装的 gdal 系统包相同版本的 pip 包。

【讨论】:

    【解决方案4】:

    我还必须包含头文件才能成功安装 gdal:

    sudo pip3 install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}') --global-option=build_ext --global-option="-I/usr/include/gdal"
    

    注意:使用 Python 3 和 gdal 已经安装在 centOS 上

    【讨论】:

      猜你喜欢
      • 2020-05-25
      • 1970-01-01
      • 2012-08-21
      • 2017-10-18
      • 2017-06-30
      • 1970-01-01
      • 2020-07-06
      • 1970-01-01
      • 2019-07-11
      相关资源
      最近更新 更多