Skip to content

Commit 5c08ab2

Browse files
authored
Use base ImportError not MoudleNotFoundError when trying to see if the (#6154)
modules load
1 parent 9226c7a commit 5c08ab2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

xarray/backends/h5netcdf_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
import h5netcdf
3636

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

4144

xarray/backends/netCDF4_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
import netCDF4
3434

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

3942

0 commit comments

Comments
 (0)