SciTools / iris-esmf-regrid

A collection of structured and unstructured ESMF regridding schemes for Iris.
https://iris-esmf-regrid.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
19 stars 17 forks source link

ImportError: The ESMFMKFILE environment variable is not available #317

Closed jamessmith1metoffice closed 10 months ago

jamessmith1metoffice commented 10 months ago
E   ImportError: The ESMFMKFILE environment variable is not available.

I got this error with the following environment:

name: stage_ngms_development
dependencies:
  - python=3.11
  - iris>=3.3.1
  - iris-grib
  - iris-esmf-regrid
  - requests
  - filelock
  - numpy
  - pytest
  - packaging
  - pre-commit

Looking at the environment creation, the underlying dependency esmf version is 8.4.2.

Any import will bring this about. For example:

from esmf_regrid.experimental.io import load_regridder
jamessmith1metoffice commented 10 months ago

I am closing this issue because I have found a workaround. For anyone coming across this, let me outline what I think the problem is.

When an environment is activated a script is executed that sets the environment variable. Thus you have to be at the command prompt or whatever from where you activated the environment. If, as in my case, you are making use of the environment from within an IDE, in my case PyCharm, then the environment variable is not going to get set when you, say, run the debugger using it.

For this reason I think that the setting of environment variables in set up scripts that are run when environments are activated is a somewhat suspect practice. In this case the environment variable points to the location of a file that could have been ascertained from a simple relative path.