离线安装GDAL库

1、下载软件包:

1.1、gdal-3.1.4.tar.gz  https://gdal.org/download.html\https://github.com/OSGeo/GDAL

1.2、 proj-6.2.1.tar.gz   https://proj.org/download.html  \https://proj.org/download.html#download

1.3、geos-3.7.3.tar.bz2  http://download.osgeo.org/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

$ python setup.py build
$ 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、https://stackoverflow.com/questions/65202037/oserror-libgdal-so-27-cannot-open-shared-object-file-no-such-file-or-director

2、https://stackoverflow.com/questions/44005694/no-module-named-gdal

3、https://blog.csdn.net/dou3516/article/details/111875619

4、https://blog.csdn.net/asd358924810/article/details/106142232/

你可能感兴趣的:(python,html,css,神经网络)