From aac8522d189fd160d8d9a69b3e336634b6ea8d3f Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 7 Oct 2023 01:52:40 -0700 Subject: [PATCH] Give a more explicit error message --- masque/pattern.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/masque/pattern.py b/masque/pattern.py index 325272d..4fae275 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -812,8 +812,13 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): overdraw: Whether to create a new figure or draw on a pre-existing one """ # TODO: add text labels to visualize() - from matplotlib import pyplot # type: ignore - import matplotlib.collections # type: ignore + try: + from matplotlib import pyplot # type: ignore + import matplotlib.collections # type: ignore + except ImportError as err: + logger.error('Pattern.visualize() depends on matplotlib!') + logger.error('Make sure to install masque with the [visualize] option to pull in the needed dependencies.') + raise err if self.has_refs() and library is None: raise PatternError('Must provide a library when visualizing a pattern with refs')