JiaweiZhuang / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
269 stars 49 forks source link

Error AttributeError: module 'ESMF' has no attribute 'api' #30

Closed yugaophd closed 5 years ago

yugaophd commented 5 years ago

I installed the required library but got the following error when import xesmf. It has problem when import ESMF. I am working under CentOS 6.5. I installed xESMF using conda install -c conda-forge esmpy.

Below is the error:

AttributeError Traceback (most recent call last)

in () 4 import numpy as np 5 import xarray as xr ----> 6 import xesmf as xe ~/local/bin/miniconda3/envs/pyenv/lib/python3.6/site-packages/xesmf/__init__.py in () 1 from . import util 2 from . import data ----> 3 from . frontend import Regridder ~/local/bin/miniconda3/envs/pyenv/lib/python3.6/site-packages/xesmf/frontend.py in () 7 import os 8 ----> 9 from . backend import (esmf_grid, add_corner, 10 esmf_regrid_build, esmf_regrid_finalize) 11 ~/local/bin/miniconda3/envs/pyenv/lib/python3.6/site-packages/xesmf/backend.py in () 17 18 import numpy as np ---> 19 import ESMF 20 import warnings 21 import os ~/local/bin/miniconda3/envs/pyenv/lib/python3.6/site-packages/ESMF/__init__.py in () 54 #### IMPORT LIBRARIES ######################################################### 55 ---> 56 from ESMF.api.esmpymanager import * 57 from ESMF.api.grid import * 58 from ESMF.api.mesh import * ~/local/bin/miniconda3/envs/pyenv/lib/python3.6/site-packages/ESMF/api/esmpymanager.py in () 9 from ESMF.api.constants import * 10 from ESMF.util.exceptions import * ---> 11 from ESMF.interface.cbindings import * 12 from ESMF.util.decorators import initialize 13 ~/local/bin/miniconda3/envs/pyenv/lib/python3.6/site-packages/ESMF/interface/cbindings.py in () 9 import sys 10 ---> 11 import ESMF.api.constants as constants 12 from ESMF.util.decorators import deprecated, netcdf 13 from ESMF.interface.loadESMF import _ESMF AttributeError: module 'ESMF' has no attribute 'api'
JiaweiZhuang commented 5 years ago

Seems the same as #19. Does the workaround there work?

yugaophd commented 5 years ago

I did try but it seems irrelevant. the error happened before importing netcdf:

error---> 11 import ESMF.api.constants as constants 12 from ESMF.util.decorators import deprecated, netcdf 13 from ESMF.interface.loadESMF import _ESMF

I think this is related to the Operating System(Centos) because ESMF works fine under Mac OS.

JiaweiZhuang commented 5 years ago

I can only find CentOS 6.6 on Docker Hub: https://hub.docker.com/_/centos/

It seems to work fine:

$ docker pull centos:6.6
$ docker run --rm -it centos:6.6 /bin/bash
$ yum install -y wget bzip2 tar which
$ cd $HOME
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
$ bash miniconda.sh -b -p $HOME/miniconda
$ export PATH=$HOME/miniconda/bin:$PATH
$ conda install -c conda-forge esmpy
$ python -c 'import ESMF'  # no error
JiaweiZhuang commented 5 years ago

OK I found a terribly old AMI on AWS: https://aws.amazon.com/marketplace/pp/B00IOYDTV6 (It is so old that it doesn't even support recent hardware types!)

But I can still run the above commands to install and import ESMPy without problems. Not sure how to reproduce your error...

JiaweiZhuang commented 5 years ago

Closing as no further responses. Feel free to re-open.