diff --git a/pyomo/contrib/interior_point/interface.py b/pyomo/contrib/interior_point/interface.py index 93b83f385ba..e95327072d8 100644 --- a/pyomo/contrib/interior_point/interface.py +++ b/pyomo/contrib/interior_point/interface.py @@ -11,7 +11,30 @@ from abc import ABCMeta, abstractmethod from pyomo.contrib.pynumero.interfaces import pyomo_nlp, ampl_nlp -from pyomo.contrib.pynumero.sparse import BlockMatrix, BlockVector +try: + from pyomo.contrib.pynumero.sparse import BlockVector, BlockMatrix +except ImportError as e: + print("IMPORT ERROR: ", e) + print("Current environment information...") + import sys + import platform + import pkg_resources + + print(f"Python version: {platform.python_version()}") + print(f"Python executable: {sys.executable}") + print(f"Platform: {platform.system()} {platform.release()} ({platform.platform()})") + + print("\nInstalled packages:") + installed_packages = pkg_resources.working_set + installed_packages_list = sorted( + [f"{pkg.key}=={pkg.version}" for pkg in installed_packages] + ) + print("\n".join(installed_packages_list)) + + print("\nImported packages:") + imported_packages = sorted(sys.modules.keys()) + print("\n".join(imported_packages)) + raise e import numpy as np import scipy.sparse from pyomo.common.timing import HierarchicalTimer diff --git a/pyomo/contrib/pynumero/linalg/base.py b/pyomo/contrib/pynumero/linalg/base.py index 0c1fc8947b2..ef8698e5100 100644 --- a/pyomo/contrib/pynumero/linalg/base.py +++ b/pyomo/contrib/pynumero/linalg/base.py @@ -15,11 +15,10 @@ from scipy.sparse import spmatrix import numpy as np +from pyomo.contrib.pynumero.sparse.base_block import BaseBlockVector, BaseBlockMatrix + try: - from pyomo.contrib.pynumero.sparse.base_block import ( - BaseBlockVector, - BaseBlockMatrix, - ) + from pyomo.contrib.pynumero.sparse import BlockVector, BlockMatrix except ImportError as e: print("IMPORT ERROR: ", e) print("Current environment information...") @@ -42,7 +41,6 @@ imported_packages = sorted(sys.modules.keys()) print("\n".join(imported_packages)) raise e -from pyomo.contrib.pynumero.sparse import BlockVector, BlockMatrix class LinearSolverStatus(enum.Enum):