From 2bb5d20fb2b4158390ab05aa6bf598b78f2caa9d Mon Sep 17 00:00:00 2001 From: keewis Date: Mon, 17 May 2021 14:56:39 +0200 Subject: [PATCH] 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] --- setup.cfg | 1 + xarray/tutorial.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index aea5cd11ffd..b425d1f66e0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -90,6 +90,7 @@ io = cftime rasterio cfgrib + pooch ## Scitools packages & dependencies (e.g: cartopy, cf-units) can be hard to install # scitools-iris diff --git a/xarray/tutorial.py b/xarray/tutorial.py index 62762d29216..f74155120ab 100644 --- a/xarray/tutorial.py +++ b/xarray/tutorial.py @@ -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") @@ -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")