diff --git a/pyomo/contrib/edi/formulation.py b/pyomo/contrib/edi/formulation.py index f0652771ec2..caee5f9fb60 100644 --- a/pyomo/contrib/edi/formulation.py +++ b/pyomo/contrib/edi/formulation.py @@ -22,10 +22,20 @@ from pyomo.environ import Var, Param, Objective, Constraint, Set from pyomo.environ import maximize, minimize from pyomo.environ import units as pyomo_units -from pyomo.contrib.pynumero.interfaces.external_grey_box import ( - ExternalGreyBoxModel, - ExternalGreyBoxBlock, + +egb, egb_available = attempt_import( + "pyomo.contrib.pynumero.interfaces.external_grey_box" ) +if egb_available: + from pyomo.contrib.pynumero.interfaces.external_grey_box import ( + ExternalGreyBoxModel, + ExternalGreyBoxBlock, + ) +else: + raise ImportError( + "pyomo.contrib.edi requires pyomo.contrib.pynumero to be installed to enable black box capability, this should have installed with base pyomo" + ) + from pyomo.environ import ( Reals, PositiveReals,