Skip to content

Commit 2bb5d20

Browse files
authored
improve the error message when pooch is not installed (#5312)
* improve the error message when pooch is not installed * add pooch to "pip install xarray[io]" [skip-ci] * don't mention of pypi and conda [skip-ci]
1 parent 2578fc3 commit 2bb5d20

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ io =
9090
cftime
9191
rasterio
9292
cfgrib
93+
pooch
9394
## Scitools packages & dependencies (e.g: cartopy, cf-units) can be hard to install
9495
# scitools-iris
9596

xarray/tutorial.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ def open_dataset(
7777
"""
7878
try:
7979
import pooch
80-
except ImportError:
81-
raise ImportError("using the tutorial data requires pooch")
80+
except ImportError as e:
81+
raise ImportError(
82+
"tutorial.open_dataset depends on pooch to download and manage datasets."
83+
" To proceed please install pooch."
84+
) from e
8285

8386
logger = pooch.get_logger()
8487
logger.setLevel("WARNING")
@@ -146,8 +149,11 @@ def open_rasterio(
146149
"""
147150
try:
148151
import pooch
149-
except ImportError:
150-
raise ImportError("using the tutorial data requires pooch")
152+
except ImportError as e:
153+
raise ImportError(
154+
"tutorial.open_rasterio depends on pooch to download and manage datasets."
155+
" To proceed please install pooch."
156+
) from e
151157

152158
logger = pooch.get_logger()
153159
logger.setLevel("WARNING")

0 commit comments

Comments
 (0)