在Linx Mint上安装GDAL

时间:2016-11-29 19:06:08

标签: python linux gdal linuxmint

我在我的Linux机器上使用Anaconda安装了GDAL

conda install gdal

但我无法加载它。如果我运行Python

   import gdal
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-27bf4694dd2b> in <module>()
----> 1 import gdal

/home/auerilas/anaconda3/lib/python3.5/site-packages/gdal.py in <module>()
      1 # import osgeo.gdal as a convenience
----> 2 from osgeo.gdal import deprecation_warn
      3 deprecation_warn('gdal')
      4
      5 from osgeo.gdal import *

/home/auerilas/anaconda3/lib/python3.5/site-packages/osgeo/__init__.py in <module>()
     19                 fp.close()
     20             return _mod
---> 21     _gdal = swig_import_helper()
     22     del swig_import_helper
     23 else:

/home/auerilas/anaconda3/lib/python3.5/site-packages/osgeo/__init__.py in swig_import_helper()
     15         if fp is not None:
     16             try:
---> 17                 _mod = imp.load_module('_gdal', fp, pathname, description)
     18             finally:
     19                 fp.close()

/home/auerilas/anaconda3/lib/python3.5/imp.py in load_module(name, file, filename, details)
    240                 return load_dynamic(name, filename, opened_file)
    241         else:
--> 242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:
    244         return load_package(name, filename)

/home/auerilas/anaconda3/lib/python3.5/imp.py in load_dynamic(name, path, file)
    340         spec = importlib.machinery.ModuleSpec(
    341             name=name, loader=loader, origin=path)
--> 342         return _load(spec)
    343
    344 else:

ImportError: libnetcdf.so.7: cannot open shared object file: No such file or directory

如果我尝试从命令行运行gdal

,我会遇到同样的错误
gdalwarp
gdalwarp: error while loading shared libraries: libnetcdf.so.7: cannot open shared object file: No such file or directory

但是,看起来好像已经安装了libnetcdf:

ls -R | grep libnetcdf
libnetcdf-4.4.1-0.json
libnetcdf.a
libnetcdf.la
libnetcdf.settings
libnetcdf.so
libnetcdf.so.11
libnetcdf.so.11.0.3
libnetcdf-4.4.1-0
libnetcdf-4.4.1-0.tar.bz2
./anaconda3/pkgs/libnetcdf-4.4.1-0:
./anaconda3/pkgs/libnetcdf-4.4.1-0/bin:
./anaconda3/pkgs/libnetcdf-4.4.1-0/include:
./anaconda3/pkgs/libnetcdf-4.4.1-0/info:
./anaconda3/pkgs/libnetcdf-4.4.1-0/lib:
libnetcdf.a
libnetcdf.la
libnetcdf.settings
libnetcdf.so
libnetcdf.so.11
libnetcdf.so.11.0.3
./anaconda3/pkgs/libnetcdf-4.4.1-0/lib/pkgconfig:

有没有人有任何想法?我尝试从源代码编译gdal,但这不起作用,我遇到一个关于gdalinfo缺失的错误。但是,gdal配置工作

gdal-config --version
2.0.0

我也尝试过

sudo apt-get install libgdal1-dev

更新

我通过关注破坏的链接将更新破解为一起。当我安装gdal时,我有libnetcdf.so.11,libkea.so.1.4.6和libhdf5_cpp.so.12。但gdal正在寻找libnetcdf.so.7,libkea.so.1.4.5和libhdf5_cpp.10。我做了以下符号链接:

cd ~/anaconda3/lib
ln -s libnetcdf.so.11 libnetcdf.so.7
ln -s libkea.so.1.4.6 libkea.so.1.4.5
ln -s libhdf5_cpp.12 libhdf5_cpp.10

它工作正常。在安装中,gdal试图通过特定版本而不是通用libnetcdf.so来查找库。如果gdal使用通用的非版本化文件,那些文件将充当当前版本的符号链接。关于gdal / Anaconda devs的发布地点的任何想法?

0 个答案:

没有答案