簡體   English   中英

安裝 GDAL 時出錯

[英]Error while installing 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

我使用了這些命令:

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

誰能告訴我如何安裝它?

檢查您是否使用此命令安裝了 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

在我的 MacBook 上,使用這種方法和 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
pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')

這是 nicerobot 對此評論的復制粘貼,此時獲得的贊成票比所有當前發布的答案加起來還要多。

據我所知,它要求 pip 安裝與已安裝的 gdal 系統包相同版本的 pip 包。

我還必須包含頭文件才能成功安裝 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 上

首先,激活您要安裝 gdal 的環境 然后簡單地嘗試命令:

[conda install -c conda-forge gdal]

請參閱此鏈接 希望這可以幫助!!

引用@nicerobot 評論,並添加一個命令以使其在遇到以下情況時起作用

錯誤:找不到滿足 GDAL 要求的版本

sudo apt install libgdal-dev
pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM