Skip to content

Commit

Permalink
improve the error message when pooch is not installed (pydata#5312)
Browse files Browse the repository at this point in the history
* 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]
  • Loading branch information
keewis authored May 17, 2021
1 parent 2578fc3 commit 2bb5d20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ io =
cftime
rasterio
cfgrib
pooch
## Scitools packages & dependencies (e.g: cartopy, cf-units) can be hard to install
# scitools-iris

Expand Down
14 changes: 10 additions & 4 deletions xarray/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ def open_dataset(
"""
try:
import pooch
except ImportError:
raise ImportError("using the tutorial data requires pooch")
except ImportError as e:
raise ImportError(
"tutorial.open_dataset depends on pooch to download and manage datasets."
" To proceed please install pooch."
) from e

logger = pooch.get_logger()
logger.setLevel("WARNING")
Expand Down Expand Up @@ -146,8 +149,11 @@ def open_rasterio(
"""
try:
import pooch
except ImportError:
raise ImportError("using the tutorial data requires pooch")
except ImportError as e:
raise ImportError(
"tutorial.open_rasterio depends on pooch to download and manage datasets."
" To proceed please install pooch."
) from e

logger = pooch.get_logger()
logger.setLevel("WARNING")
Expand Down

0 comments on commit 2bb5d20

Please sign in to comment.