安装GDAL时出错

Rah*_*hul 25 python pip gdal

我正在尝试通过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
Run Code Online (Sandbox Code Playgroud)

我使用了这些命令:

sudo apt-get install libgdal-dev
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL
Run Code Online (Sandbox Code Playgroud)

谁能告诉我如何安装它?

Dim*_*osh 18

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

gdal-config --version
Run Code Online (Sandbox Code Playgroud)

然后运行以下命令:

pip install --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
Run Code Online (Sandbox Code Playgroud)

  • `pip install GDAL == $(gdal-config --version | awk -F'[.]''{print $ 1"."$ 2}')` (43认同)
  • 对于其他人而言,根据您安装GDAL的方式,您可能会为缺少的头文件提供不同的位置.我通过kyngchaos安装,对我来说正确的路径是:`--include-dirs =/Library/Frameworks/GDAL.framework/Versions/2.1/Headers /` (2认同)

fel*_*ice 13

在我的MacBook上,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
Run Code Online (Sandbox Code Playgroud)

验证:

$> 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
Run Code Online (Sandbox Code Playgroud)

  • 不得不混合使用上面的一些答案,但是在我的Mac上运行el capitan就可以了!在使用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}')` (4认同)
  • 你需要先做上面的“简而言之解决方案”,然后做“验证”,最后做`pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1" ."$2}')` 来自 imapotoatoe123。 (2认同)

Dom*_*kis 10

pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')
Run Code Online (Sandbox Code Playgroud)

这是nicerobot对这条评论的复制粘贴,此时收到的票数比所有当前发布的答案总和还要多。

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