From 2fe851b9dde5e30dc5597d6c64c4eed4a1186aa1 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Wed, 26 Jul 2023 10:15:26 -0500 Subject: [PATCH] feat: improved error messages when missing backend dependencies --- ibis/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ibis/__init__.py b/ibis/__init__.py index 2c4daf04c98a..7e4d0dba3e44 100644 --- a/ibis/__init__.py +++ b/ibis/__init__.py @@ -72,7 +72,15 @@ def __getattr__(name: str) -> BaseBackend: import ibis (entry_point,) = entry_points - module = entry_point.load() + try: + module = entry_point.load() + except ImportError as exc: + raise ImportError( + f"Failed to import the {name} backend due to missing dependencies.\n\n" + f"You can pip or conda install the {name} backend as follows:\n\n" + f' python -m pip install -U "ibis-framework[{name}]" # pip install\n' + f" conda install -c conda-forge ibis-{name} # or conda install" + ) from exc backend = module.Backend() # The first time a backend is loaded, we register its options, and we set # it as an attribute of `ibis`, so `__getattr__` is not called again for it