需要安装的库:(1)anaconda3(2)basemap (3)eccodes(4)jasper(5)pygrib
步骤:
(1)安装anaconda3
在https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/中选择一个版本进行下载,
我选择的是4.4.0版本,下载:wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.4.0-Linux-x86_64.sh
安装:sh Anaconda3-4.4.0-Linux-x86_64.sh
然后通过软连接,将anaconda中的python和pip链接到/usr/bin目录下,分别命名为python3和pip3
(2)安装basemap
pip3 install basemap
可能会报错,说少pyproj和pyshp,直接pip3 install pyproj和pip3 install pyshp即可
(3)安装jasper
yum install jasper
(4)安装ecCodes所需的额外支持库
yum -y install gcc gcc-c++ numpy python-devel scipy
yum -y install gcc-gfortran
yum -y install cmake
yum -y install jasper
yum -y install jasper-devel
yum -y install openjpeg
yum -y install openjpeg-devel
yum -y install git
(5)安装ecCodes
eccodes安装包下载地址:https://confluence.ecmwf.int//display/ECC/Releases
我是安装的2.10.0版本,下载:wget https://confluence.ecmwf.int/download/attachments/45757960/eccodes-2.10.0-Source.tar.gz?api=v2
解压之后,进入解压后的文件夹:
mkdir build
cd build
cmake ../../eccodes-2.10.0-Source -DCMAKE_INSTALL_PREFIX=/usr/local/lib
make
make install
(6)安装pygrib
wget https://pypi.python.org/packages/3c/16/d128a64f2f5e9f776d6e080ba62551b5d103a4c0acb283204135bd23f14e/pygrib-2.0.2.tar.gz
tar xzvf pygrib-2.0.2.tar.gz
cd pygrib-2.0.2/
python3 setup.py install
(7)在python3控制台import pygrib,可能会出现一下错误
>>> import pygrib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libgrib_api.so.1: cannot open shared object file: No such file or directory
解决方法:
$locate libgrib_api.so.1 #查找libgrib_api.so.1的位置
/usr/local/lib/libgrib_api.so.1
vi .bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
然后保存,再source .bashrc即可