From d68e899798ac3ca8dcb2b4185362aecbc3ec800e Mon Sep 17 00:00:00 2001 From: Angus McBride Date: Tue, 23 Dec 2025 12:25:44 +0100 Subject: [PATCH] Warn on failing imports --- epyt/epanet.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/epyt/epanet.py b/epyt/epanet.py index 6df2908..e1ba91d 100644 --- a/epyt/epanet.py +++ b/epyt/epanet.py @@ -83,11 +83,23 @@ from shutil import copyfile from types import SimpleNamespace -import matplotlib as mpl -import matplotlib.pyplot as plt -import numpy as np -import pandas as pd -from matplotlib import cm + +try: + import matplotlib as mpl + import matplotlib.pyplot as plt + from matplotlib import cm +except ImportError: + warnings.warn("matplotlib is not installed. Plotting functions will not work.") + +try: + import numpy as np +except ImportError: + warnings.warn("numpy is not installed. Some functions will not work.") + +try: + import pandas as pd +except ImportError: + warnings.warn("pandas is not installed. Excel functions will not work.") epyt_root = str(files("epyt"))