jkrasting / momgrid

Flexible Grid Object for MOM-based Ocean Models
Other
0 stars 3 forks source link

ESMF and ESMpy versions incompatible? #42

Open hdrake opened 3 months ago

hdrake commented 3 months ago

When I try to

import momgrid

within the /nbhome/jpk/envs/py311 environment, I get the following error about inconsistent packages.

---------------------------------------------------------------------------
VersionMismatch                           Traceback (most recent call last)
Cell In[38], line 2
      1 # momgrid will use a directory of pre-computed weights that is used for calculating basic area-weighted statistics later
----> 2 import momgrid
      3 os.environ["MOMGRID_WEIGHTS_DIR"] = "[/nbhome/John.Krasting/grid_weights](http://localhost:5555/nbhome/John.Krasting/grid_weights)"

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/momgrid/__init__.py:19](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/momgrid/__init__.py#line=18)
     17 from . import plot
     18 from . import util
---> 19 from . import external
     20 from . import vertical
     21 from . import comparison

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/momgrid/external.py:5](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/momgrid/external.py#line=4)
      3 import warnings
      4 import xarray as xr
----> 5 import xesmf as xe
      6 import pkg_resources as pkgr
      7 from momgrid.util import is_symmetric

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/xesmf/__init__.py:4](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/xesmf/__init__.py#line=3)
      1 # flake8: noqa
      3 from . import data, util
----> 4 from .frontend import Regridder, SpatialAverager
      6 try:
      7     from ._version import __version__

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/xesmf/frontend.py:14](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/xesmf/frontend.py#line=13)
     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 [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/xesmf/backend.py:22](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/xesmf/backend.py#line=21)
     19 import warnings
     21 try:
---> 22     import esmpy as ESMF
     23 except ImportError:
     24     import ESMF

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/__init__.py:112](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/__init__.py#line=111)
    108 __obsoletes__ = msg["obsoletes"]
    110 #### IMPORT LIBRARIES #########################################################
--> 112 from esmpy.api.esmpymanager import *
    113 from esmpy.api.grid import *
    114 from esmpy.api.mesh import *

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/api/esmpymanager.py:9](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/api/esmpymanager.py#line=8)
      3 """
      4 The ESMPyManager API
      5 """
      7 #### IMPORT LIBRARIES #########################################################
----> 9 from esmpy.interface.cbindings import *
     11 from esmpy.api.constants import *
     12 from esmpy.util.exceptions import *

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/interface/cbindings.py:13](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/interface/cbindings.py#line=12)
     11 import esmpy.api.constants as constants
     12 from esmpy.util.decorators import *
---> 13 from esmpy.interface.loadESMF import _ESMF
     16 def copy_struct(src):
     17     dst = type(src)()

File [/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/interface/loadESMF.py:77](http://localhost:5555/nbhome/jpk/envs/py311/lib/python3.11/site-packages/esmpy/interface/loadESMF.py#line=76)
     74 if esmfversion != constants._ESMPY_VERSION:
     75     # check if major, minor and patch version numbers are equivalent
     76     if esmfvs[0:2] != esmpyvs[0:2]:
---> 77         raise VersionMismatch("ESMF installation version {}, ESMPy version {}".format(
     78             esmfversion, constants._ESMPY_VERSION))
     79     # otherwise warn that beta versions may be in use
     80     else:
     81         import warnings

VersionMismatch: ESMF installation version 8.6.0, ESMPy version 8.4.2

Because of this, I currently cannot run my MAR notebook for bottom properties. I developed the notebook in a separate environment where I locally installed momgrid and momlevel myself with pip.

jkrasting commented 3 months ago

I was not able to replicate this error on my end, @hdrake . Is it possible you have a conflict in your user / local environment? Check $HOME/.local/python3.11 ....

hdrake commented 3 months ago

That's possible, but I thought that the whole point of using a conda environment was that it protects against this?

jkrasting commented 3 months ago

That was what I had hoped. There would need to be a way to disable the local search paths (if this is indeed the issue). Let's connect on slack.