I try to run this script in a SH file this script python3.6 Scriptfile.py /route
The script:
import os
import xarray as xr
import ecmwflibs
import cfgrib
import sys
data_path = r'/grib' + '/'
ds = xr.open_mfdataset(data_path+'*',engine="cfgrib", combine = 'nested', backend_kwargs={'filter_by_keys': {'stepType': 'accum'}}, concat_dim='step')
It returns this erros:
Traceback (most recent call last):
File "Scriptfile.py", line 20, in <module>
import ecmwflibs
ModuleNotFoundError: No module named 'ecmwflibs'
If I comment the line import ecmwflibs, it returns:
Traceback (most recent call last):
File "Scriptfile.py", line 20, in <module>
import cfgrib
ModuleNotFoundError: No module named 'cfgrib'
The libraries are installed:
$ python3.6 -m pip list | egrep "(eccodes|ecmwflib|cfgrib)"
cfgrib 0.9.10.0
eccodes 1.2.0
ecmwflibs 0.5.0
pyeccodes 0.1.1
The problem it seems to be an incorrect PATH definition? echo $PATH
/home/XXXX/.local/bin:
/home/XXXX/bin:
/home/XXXX/.local/bin:
/home/XXXX/bin:
/home/XXXX/.local/bin:
/home/XXXX/bin:
/home/XXXX/miniconda3/bin:
/home/XXXX/miniconda3/condabin:
/home/XXXX/.local/bin:
/home/XXXX/bin:
/sbin:
/bin:
/usr/bin:
/usr/local/bin:
/usr/local/sbin:
/usr/sbin
I figured out how to solve this issue when I tried to re-install ecmwflibs via pip:
I solved the problem by adding to path also /home/user/.local/lib/python3.7/site-packages, so in your case should be something like
Hope this will solve your issue