当前位置:   article > 正文

离线安装GDAL库_gdal离线安装

gdal离线安装

1、下载软件包:

1.1、gdal-3.1.4.tar.gz  Download — GDAL documentation\GitHub - OSGeo/gdal: GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.

1.2、 proj-6.2.1.tar.gz   Download — PROJ 9.3.0 documentation  \Download — PROJ 9.3.0 documentation

1.3、geos-3.7.3.tar.bz2  Index of /geos/

2、安装步奏

2.1、安装proj
tar -xf proj-6.2.0.tar.gz  #解压
cd proj-6.2.0    #进入解压目录
./configure --prefix=/home/share/wli/software/proj/6.2.0
make
make install
2.2、安装gdal
./configure --prefix=/home/share/wli/software/gdal/2.2.3
make
make install
2.3、安装python版的gdal
cd /gdal-2.2.3/swig/python/
python setup.py build
python setup.py install

  1. $ python setup.py build
  2. $ python setup.py install


 2.4、import gdal 会报:No module named _gdal
生成指定变量 (gdal位置 显示安装结束前 Installed  /home/.../.egg)
export PYTHONPATH=/home/share/wli/software/anaconda3c/lib/python3.7/site-packages/GDAL-2.2.2-py3.7-linux-x86_64.egg/osgeo/:$PYTHONPATH
5、最后import gdal 测试出现

OSError: libgdal.so.27: cannot open shared object file: No such file or directory

解决办法:

查了一下错误原因,原来是系统不知道GDAL共享库的加载路径。在~/.bashrc中加入一行: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib,然后执行source .bashrc。问题解决,大功告成。
$ python
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gdal

3、参考博客

1、python 3.x - OSError: libgdal.so.27: cannot open shared object file: No such file or directory - Stack Overflow

2、python - No module named _gdal - Stack Overflow

3、main__.gdal_config_error: [Errno 2] No such file or directory: ‘gdal-config (gdal源码安装)-CSDN博客

4、Linux下离线安装Python的GDAL包-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/172405
推荐阅读
相关标签
  

闽ICP备14008679号