Closed durack1 closed 6 months ago
I just tried the same again today (Wed 10 Apr), and hit the same problem with a "Climate notebook":
import xcdat
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/esmpy/interface/loadESMF.py:26
25 try:
---> 26 esmfmk = os.environ["ESMFMKFILE"]
27 except:
File /opt/conda/lib/python3.10/os.py:680, in _Environ.__getitem__(self, key)
678 except KeyError:
679 # raise KeyError with the original key value
--> 680 raise KeyError(key) from None
681 return self.decodevalue(value)
KeyError: 'ESMFMKFILE'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/xesmf/backend.py:22
21 try:
---> 22 import esmpy as ESMF
23 except ImportError:
File /opt/conda/lib/python3.10/site-packages/esmpy/__init__.py:112
110 #### IMPORT LIBRARIES #########################################################
--> 112 from esmpy.api.esmpymanager import *
113 from esmpy.api.grid import *
File /opt/conda/lib/python3.10/site-packages/esmpy/api/esmpymanager.py:9
7 #### IMPORT LIBRARIES #########################################################
----> 9 from esmpy.interface.cbindings import *
11 from esmpy.api.constants import *
File /opt/conda/lib/python3.10/site-packages/esmpy/interface/cbindings.py:13
12 from esmpy.util.decorators import *
---> 13 from esmpy.interface.loadESMF import _ESMF
16 def copy_struct(src):
File /opt/conda/lib/python3.10/site-packages/esmpy/interface/loadESMF.py:28
27 except:
---> 28 raise ImportError('The ESMFMKFILE environment variable is not available.')
30 #### INVESTIGATE esmf.mk ######################################################
31
32 # TODO: look for various dependecies in the ESMF build log
(...)
37 # use this information to set variables that can be checked at beginning
38 # of the routines that require an ESMF build with these dependencies
ImportError: The ESMFMKFILE environment variable is not available.
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
File <timed exec>:3
File /opt/conda/lib/python3.10/site-packages/xcdat/__init__.py:10
8 from xcdat.bounds import BoundsAccessor # noqa: F401
9 from xcdat.dataset import decode_time, open_dataset, open_mfdataset # noqa: F401
---> 10 from xcdat.regridder.accessor import RegridderAccessor # noqa: F401
11 from xcdat.regridder.grid import ( # noqa: F401
12 create_axis,
13 create_gaussian_grid,
(...)
17 create_zonal_grid,
18 )
19 from xcdat.spatial import SpatialAccessor # noqa: F401
File /opt/conda/lib/python3.10/site-packages/xcdat/regridder/__init__.py:1
----> 1 from xcdat.regridder.accessor import RegridderAccessor
2 from xcdat.regridder.regrid2 import Regrid2Regridder
3 from xcdat.regridder.xesmf import XESMFRegridder
File /opt/conda/lib/python3.10/site-packages/xcdat/regridder/accessor.py:9
6 import xarray as xr
8 from xcdat.axis import CFAxisKey, get_dim_coords
----> 9 from xcdat.regridder import regrid2, xesmf, xgcm
10 from xcdat.regridder.grid import _validate_grid_has_single_axis_dim
12 HorizontalRegridTools = Literal["xesmf", "regrid2"]
File /opt/conda/lib/python3.10/site-packages/xcdat/regridder/xesmf.py:4
1 from typing import Any, Optional
3 import xarray as xr
----> 4 import xesmf as xe
6 from xcdat.regridder.base import BaseRegridder, _preserve_bounds
8 VALID_METHODS = [
9 "bilinear",
10 "conservative",
(...)
14 "nearest_d2s",
15 ]
File /opt/conda/lib/python3.10/site-packages/xesmf/__init__.py:4
1 # flake8: noqa
3 from . import data, util
----> 4 from .frontend import Regridder, SpatialAverager
6 try:
7 from ._version import __version__
File /opt/conda/lib/python3.10/site-packages/xesmf/frontend.py:14
11 from shapely.geometry import LineString
12 from xarray import DataArray, Dataset
---> 14 from .backend import Grid, LocStream, Mesh, add_corner, esmf_regrid_build, esmf_regrid_finalize
15 from .smm import (
16 _combine_weight_multipoly,
17 _parse_coords_and_values,
(...)
21 read_weights,
22 )
23 from .util import LAT_CF_ATTRS, LON_CF_ATTRS, split_polygons_and_holes
File /opt/conda/lib/python3.10/site-packages/xesmf/backend.py:24
22 import esmpy as ESMF
23 except ImportError:
---> 24 import ESMF
25 import numpy as np
26 import numpy.lib.recfunctions as nprec
ModuleNotFoundError: No module named 'ESMF'
@jasonb5 let me know if additional context/info is required?
@durack1 I believe the newer versions of ESMF have this fixed, I tested with 8.2.0 and didn't see this issue. If you're using an older version of ESMF then you would need to add the following cell before any imports in a notebook.
import os
os.environ["ESMFMKFILE"] = "/opt/conda/lib/esmf.mk"
@durack1 Is this fixed in the most recent environments?
@jasonb5 just checked and we're all fixed with the new xcdat 0.7.0
climate environment you created, thanks!
Describe the bug Attempting to import
xcdat
on Nimbus currently returns an error associated with ESMF.To Reproduce Steps to reproduce the behavior:
import xcdat as xc
Expected behavior This should launch, but instead returns an error:
Screenshots See above
Desktop (please complete the following information): Nimbus jupyterhub env - current "Climate notebook" env
Additional context nil
@mbarcodia ping