我正在尝试使用ECMWF GRIB_API从Python访问GRIB文件。我收到此错误
onReceivedError
一行代码:)
Traceback (most recent call last):
File "/home/martin/markj/JustImportGRIB.py", line 1, in <module>
from gribapi import *
ImportError: No module named gribapi
我正在使用Anaconda Python 2.7.12,Linux Centos 64位,作为用户安装,如果相关的话,系统Python(2.6)不在路径上,而不是将Anaconda添加到路径中。我从Pingu Carsti channel安装了GRIB_API,这是谷歌的热门搜索。 conda安装没有报告任何错误。
from gribapi import *
我发现some bug reports有关此错误是由ECMWF GRIB_API中的错误引起的,但我对Anaconda(或Python)的了解不足以了解如何应用{{3} }。
答案 0 :(得分:1)
我使用pygrib在Python中读取GRIB文件。我已成功将其安装在conda虚拟环境中(Ubuntu 16.04上的Miniconda2)。这对我有用:
为pygrib安装系统依赖项:
sudo apt-get install libjpeg9
sudo apt-get install libgrib-api-dev
从conda-forge频道安装pygrib和ecmwf_grib。
conda install -c conda-forge pygrib ecmwf_grib
答案 1 :(得分:1)
尝试使用 python-eccodes 进行conda-forge构建(注意:那不是 eccodes ,这是C库)。
如何构建:https://github.com/conda-forge/python-eccodes-feedstock/blob/master/recipe/meta.yaml
ECMWF的ecCodes库是其GRIB API的下一个版本,与旧的GRIB API非常相似。
pelson> conda create -n gribby -c conda-forge python-eccodes
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment /Users/pelson/miniconda/envs/gribby:
The following NEW packages will be INSTALLED:
ca-certificates: 2017.7.27.1-0 conda-forge
curl: 7.54.1-0 conda-forge
eccodes: 2.4.0-0 conda-forge
hdf4: 4.2.12-0 conda-forge
hdf5: 1.8.18-1 conda-forge
intel-openmp: 2018.0.0-h68bdfb3_7 defaults
jasper: 1.900.1-4 conda-forge
jpeg: 9b-1 conda-forge
krb5: 1.14.2-0 conda-forge
libgfortran: 3.0.1-h93005f0_2 defaults
libnetcdf: 4.4.1.1-8 conda-forge
libpng: 1.6.28-1 conda-forge
libssh2: 1.8.0-1 conda-forge
mkl: 2018.0.0-h5ef208c_6 defaults
ncurses: 5.9-10 conda-forge
numpy: 1.13.3-py27h62f9060_0 defaults
openssl: 1.0.2l-0 conda-forge
python: 2.7.14-0 conda-forge
python-eccodes: 2.4.0-py27_1 conda-forge
readline: 6.2-0 conda-forge
sqlite: 3.13.0-1 conda-forge
tk: 8.5.19-2 conda-forge
zlib: 1.2.8-3 conda-forge
#
# To activate this environment, use:
# > source activate gribby
#
# To deactivate an active environment, use:
# > source deactivate
#
pelson> source activate gribby
python(gribby) pelson> python
Python 2.7.14 | packaged by conda-forge | (default, Oct 5 2017, 23:08:53)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gribapi
>>> gribapi.__version__
'2.4.0'