Skip to content

Commit

Permalink
Use base ImportError not MoudleNotFoundError when trying to see if the (
Browse files Browse the repository at this point in the history
#6154)

modules load
  • Loading branch information
hmaarrfk authored Jan 11, 2022
1 parent 9226c7a commit 5c08ab2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
import h5netcdf

has_h5netcdf = True
except ModuleNotFoundError:
except ImportError:
# Except a base ImportError (not ModuleNotFoundError) to catch usecases
# where errors have mismatched versions of c-dependencies. This can happen
# when developers are making changes them.
has_h5netcdf = False


Expand Down
5 changes: 4 additions & 1 deletion xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
import netCDF4

has_netcdf4 = True
except ModuleNotFoundError:
except ImportError:
# Except a base ImportError (not ModuleNotFoundError) to catch usecases
# where errors have mismatched versions of c-dependencies. This can happen
# when developers are making changes them.
has_netcdf4 = False


Expand Down

0 comments on commit 5c08ab2

Please sign in to comment.