Repository: Pyomo/pyomo

Issue:
NameError in pyomo when import pertpy
Hello. I can't import pertpy owing to NameError. It seems to associate with pyomo(see below).
<img width="1920" alt="截屏2024-05-16 22 14 35" src="https://github.com/Pyomo/pyomo/assets/47292254/a1cd3fb4-56fa-457f-8842-47b9e8997179">
<img width="1069" alt="截屏2024-05-16 22 18 07" src="https://github.com/Pyomo/pyomo/assets/47292254/ec6f6864-8b69-4f6a-97fd-cd9472d29a6f">
NameError                                 Traceback (most recent call last)
Cell In[4], [line 3](vscode-notebook-cell:?execution_count=4&line=3)
      [1](vscode-notebook-cell:?execution_count=4&line=1) import scanpy as sc
      [2](vscode-notebook-cell:?execution_count=4&line=2) import scvelo as scv
----> [3](vscode-notebook-cell:?execution_count=4&line=3) import pertpy as pt

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/__init__.py:20
     [18](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/__init__.py:18) from . import plot as pl
     [19](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/__init__.py:19) from . import preprocessing as pp
---> [20](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/__init__.py:20) from . import tools as tl

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/__init__.py:5
      [3](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/__init__.py:3) from pertpy.tools._coda._sccoda import Sccoda
      [4](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/__init__.py:4) from pertpy.tools._coda._tasccoda import Tasccoda
----> [5](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/__init__.py:5) from pertpy.tools._dialogue import Dialogue
      [6](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/__init__.py:6) from pertpy.tools._differential_gene_expression import DifferentialGeneExpression
      [7](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/__init__.py:7) from pertpy.tools._distances._distance_tests import DistanceTest

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/_dialogue.py:25
     [23](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/_dialogue.py:23) from seaborn import PairGrid
     [24](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/_dialogue.py:24) from sklearn.linear_model import LinearRegression
---> [25](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/_dialogue.py:25) from sparsecca import lp_pmd, multicca_permute, multicca_pmd
     [26](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/_dialogue.py:26) from statsmodels.sandbox.stats.multicomp import multipletests
     [28](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pertpy/tools/_dialogue.py:28) if TYPE_CHECKING:

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/__init__.py:5
      [3](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/__init__.py:3) from ._cca_pmd import cca as cca_pmd
      [4](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/__init__.py:4) from ._multicca_pmd import multicca as multicca_pmd
----> [5](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/__init__.py:5) from ._multicca_lp import lp_pmd 
      [6](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/__init__.py:6) from ._multicca_pmd_permute import multicca_permute
      [7](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/__init__.py:7) from ._pmd import pmd

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/_multicca_lp.py:4
      [2](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/_multicca_lp.py:2) from scipy.linalg import svd
      [3](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/_multicca_lp.py:3) from collections import defaultdict
----> [4](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/_multicca_lp.py:4) import pyomo.environ as pyo
      [6](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/_multicca_lp.py:6) from ._utils_pmd import scale, preprocess_datasets
      [7](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/sparsecca/_multicca_lp.py:7) from ._utils_pmd import soft

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:86
     [82](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:82)         pkg = _sys.modules[pname]
     [83](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:83)         pkg.load()
---> [86](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:86) _import_packages()
     [88](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:88) #
     [89](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:89) # Expose the symbols from pyomo.core
     [90](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:90) #
     [91](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:91) from pyomo.dataportal import DataPortal

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:66, in _import_packages()
     [64](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:64) pname = _package + '.plugins'
     [65](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:65) try:
---> [66](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:66)     _do_import(pname)
     [67](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:67) except ImportError:
     [68](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:68)     exctype, err, tb = _sys.exc_info()  # BUG?

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:18, in _do_import(pkg_name)
     [17](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:17) def _do_import(pkg_name):
---> [18](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/environ/__init__.py:18)     importlib.import_module(pkg_name)

File /opt/miniconda3/envs/omicverse/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    [124](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/importlib/__init__.py:124)             break
    [125](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/importlib/__init__.py:125)         level += 1
--> [126](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/importlib/__init__.py:126) return _bootstrap._gcd_import(name[level:], package, level)

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:27
     [12](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:12) from pyomo.core.expr.numvalue import (
     [13](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:13)     value,
     [14](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:14)     is_constant,
   (...)
     [22](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:22)     polynomial_degree,
     [23](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:23) )
     [25](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:25) from pyomo.core.expr.boolean_value import BooleanValue
---> [27](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:27) from pyomo.core.expr import (
     [28](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:28)     linear_expression,
     [29](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:29)     nonlinear_expression,
     [30](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:30)     land,
     [31](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:31)     lor,
     [32](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:32)     equivalent,
     [33](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:33)     exactly,
     [34](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:34)     atleast,
     [35](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:35)     atmost,
     [36](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:36)     all_different,
     [37](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:37)     count_if,
     [38](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:38)     implies,
     [39](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:39)     lnot,
     [40](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:40)     xor,
     [41](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:41)     inequality,
     [42](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:42)     log,
     [43](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:43)     log10,
     [44](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:44)     sin,
     [45](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:45)     cos,
     [46](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:46)     tan,
     [47](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:47)     cosh,
     [48](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:48)     sinh,
     [49](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:49)     tanh,
     [50](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:50)     asin,
     [51](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:51)     acos,
     [52](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:52)     atan,
     [53](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:53)     exp,
     [54](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:54)     sqrt,
     [55](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:55)     asinh,
     [56](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:56)     acosh,
     [57](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:57)     atanh,
     [58](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:58)     ceil,
     [59](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:59)     floor,
     [60](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:60)     Expr_if,
     [61](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:61) )
     [63](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:63) from pyomo.core.expr.calculus.derivatives import differentiate
     [64](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/__init__.py:64) from pyomo.core.expr.taylor_series import taylor_series_expansion

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:203
    [157](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:157) from .template_expr import (
    [158](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:158)     GetItemExpression,
    [159](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:159)     Numeric_GetItemExpression,
   (...)
    [183](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:183)     templatize_constraint,
    [184](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:184) )
    [185](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:185) from .visitor import (
    [186](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:186)     StreamBasedExpressionVisitor,
    [187](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:187)     SimpleExpressionVisitor,
   (...)
    [200](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:200)     sizeof_expression,
    [201](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:201) )
--> [203](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:203) from .calculus.derivatives import differentiate
    [204](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/__init__.py:204) from .taylor_series import taylor_series_expansion

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:[1](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:1)3
      1 #  ___________________________________________________________________________
      [2](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:2) #
      [3](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:3) #  Pyomo: Python Optimization Modeling Objects
   (...)
      [9](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:9) #  This software is distributed under the 3-clause BSD License.
     [10](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:10) #  ___________________________________________________________________________
     [12](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:12) import enum
---> [13](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:13) from .diff_with_sympy import differentiate as sympy_diff
     [14](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:14) from .diff_with_pyomo import reverse_sd, reverse_ad
     [17](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py:17) class Modes(str, enum.Enum):

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:[1](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:1)2
      1 #  ___________________________________________________________________________
      [2](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:2) #
      [3](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:3) #  Pyomo: Python Optimization Modeling Objects
   (...)
      [9](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:9) #  This software is distributed under the 3-clause BSD License.
     [10](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:10) #  ___________________________________________________________________________
---> [12](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:12) from pyomo.core.expr.sympy_tools import (
     [13](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:13)     sympy_available,
     [14](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:14)     sympyify_expression,
     [15](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:15)     sympy2pyomo_expression,
     [16](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:16) )
     [18](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:18) # A "public" attribute indicating that differentiate() can be called
     [19](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:19) # ... this provides a bit of future-proofing for alternative approaches
     [20](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:20) # to symbolic differentiation.
     [21](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py:21) differentiate_available = sympy_available

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:113
     [73](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:73)     _pyomo_operator_map.update(
     [74](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:74)         {
     [75](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:75)             EXPR.SumExpression: sympy.Add,
   (...)
     [86](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:86)         }
     [87](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:87)     )
     [89](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:89)     _functionMap.update(
     [90](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:90)         {
     [91](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:91)             'exp': sympy.exp,
   (...)
    [109](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:109)         }
    [110](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:110)     )
--> [113](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:113) sympy, sympy_available = attempt_import('sympy', callback=_configure_sympy)
    [116](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:116) if sys.version_info[:2] < (3, 8):
    [118](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:118)     def _prod(args):

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:738, in attempt_import(name, error_message, only_catch_importerror, minimum_version, alt_names, callback, importer, defer_check, defer_import, deferred_submodules, catch_exceptions)
    [735](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:735) if deferred_submodules:
    [736](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:736)     raise ValueError("deferred_submodules is only valid if defer_import==True")
--> [738](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:738) return _perform_import(
    [739](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:739)     name=name,
    [740](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:740)     error_message=error_message,
    [741](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:741)     minimum_version=minimum_version,
    [742](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:742)     callback=callback,
    [743](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:743)     importer=importer,
    [744](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:744)     catch_exceptions=catch_exceptions,
    [745](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:745)     package=inspect.currentframe().f_back.f_globals.get('__name__', ''),
    [746](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:746) )

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:768, in _perform_import(name, error_message, minimum_version, callback, importer, catch_exceptions, package)
    [766](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:766) if minimum_version is None or check_min_version(module, minimum_version):
    [767](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:767)     if callback is not None:
--> [768](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:768)         callback(module, True)
    [769](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:769)     return module, True
    [770](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/common/dependencies.py:770) else:

File /opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:38, in _configure_sympy(sympy, available)
     [32](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:32) if not available:
     [33](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:33)     return
     [35](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:35) _operatorMap.update(
     [36](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:36)     {
     [37](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:37)         sympy.Add: sum,
---> [38](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:38)         sympy.Mul: _prod,
     [39](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:39)         sympy.Pow: lambda x: operator.pow(*x),
     [40](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:40)         sympy.exp: lambda x: EXPR.exp(*x),
     [41](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:41)         sympy.log: lambda x: EXPR.log(*x),
     [42](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:42)         sympy.sin: lambda x: EXPR.sin(*x),
     [43](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:43)         sympy.asin: lambda x: EXPR.asin(*x),
     [44](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:44)         sympy.sinh: lambda x: EXPR.sinh(*x),
     [45](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:45)         sympy.asinh: lambda x: EXPR.asinh(*x),
     [46](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:46)         sympy.cos: lambda x: EXPR.cos(*x),
     [47](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:47)         sympy.acos: lambda x: EXPR.acos(*x),
     [48](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:48)         sympy.cosh: lambda x: EXPR.cosh(*x),
     [49](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:49)         sympy.acosh: lambda x: EXPR.acosh(*x),
     [50](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:50)         sympy.tan: lambda x: EXPR.tan(*x),
     [51](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:51)         sympy.atan: lambda x: EXPR.atan(*x),
     [52](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:52)         sympy.tanh: lambda x: EXPR.tanh(*x),
     [53](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:53)         sympy.atanh: lambda x: EXPR.atanh(*x),
     [54](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:54)         sympy.ceiling: lambda x: EXPR.ceil(*x),
     [55](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:55)         sympy.floor: lambda x: EXPR.floor(*x),
     [56](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:56)         sympy.sqrt: lambda x: EXPR.sqrt(*x),
     [57](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:57)         sympy.Abs: lambda x: abs(*x),
     [58](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:58)         sympy.Derivative: _nondifferentiable,
     [59](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:59)         sympy.Tuple: lambda x: x,
     [60](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:60)         sympy.Or: lambda x: EXPR.lor(*x),
     [61](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:61)         sympy.And: lambda x: EXPR.land(*x),
     [62](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:62)         sympy.Implies: lambda x: EXPR.implies(*x),
     [63](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:63)         sympy.Equivalent: lambda x: EXPR.equivalents(*x),
     [64](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:64)         sympy.Not: lambda x: EXPR.lnot(*x),
     [65](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:65)         sympy.LessThan: lambda x: operator.le(*x),
     [66](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:66)         sympy.StrictLessThan: lambda x: operator.lt(*x),
     [67](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:67)         sympy.GreaterThan: lambda x: operator.ge(*x),
     [68](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:68)         sympy.StrictGreaterThan: lambda x: operator.gt(*x),
     [69](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:69)         sympy.Equality: lambda x: operator.eq(*x),
     [70](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:70)     }
     [71](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:71) )
     [73](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:73) _pyomo_operator_map.update(
     [74](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:74)     {
     [75](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:75)         EXPR.SumExpression: sympy.Add,
   (...)
     [86](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:86)     }
     [87](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:87) )
     [89](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:89) _functionMap.update(
     [90](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:90)     {
     [91](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:91)         'exp': sympy.exp,
   (...)
    [109](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:109)     }
    [110](https://file+.vscode-resource.vscode-cdn.net/opt/miniconda3/envs/omicverse/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py:110) )

NameError: name '_prod' is not defined

Any help would be greatly appreciated.
Thank you.

Alvin


Discussion:
I can confirm we're seeing the same error in some of the OMLT notebook tests using Pyomo 6.7.2. Checkout the [github action](https://github.com/cog-imperial/OMLT/actions/runs/9009456983/job/25032180088#step:8:148) for the trace. 

What is perplexing is that all of the core tests and most other notebooks pass. it is just a few notebooks that produce this error.
Running into similar issues when trying to import a module that uses pyomo on a Linux cluster. Find below the error log:
```

  
Loading python/3.10.7
  Loading requirement: openssl/1.1.1s

Loading cudnn/8.4.1-cuda11.6
  Loading requirement: cuda/11.6.2
[^[[36m2024-05-16 18:00:24,264^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Enforcing tags! <cfg.extras.enforce_tags=True>^[[0m
[^[[36m2024-05-16 18:00:24,270^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Printing config tree with Rich! <cfg.extras.print_config=True>^[[0m
[^[[36m2024-05-16 18:00:24,271^[[0m][^[[34msrc.utils.rich_utils^[[0m][^[[33mWARNING^[[0m] - [rank: 0] Field 'logger' not found in config. Skipping 'logger' config printing...^[[0m
CONFIG
├── data
│   └── _target_: src.data.perturb_datamodule.PertDataModule
│       data_dir: /data/home/bty174/scBench/data/splits/perturb
│       data_name: repogle_rpe1
"output.log" 212L, 15671C                                                                                                                                                                                        1,1           Top
Loading python/3.10.7
  Loading requirement: openssl/1.1.1s

Loading cudnn/8.4.1-cuda11.6
  Loading requirement: cuda/11.6.2
[^[[36m2024-05-16 18:00:24,264^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Enforcing tags! <cfg.extras.enforce_tags=True>^[[0m
[^[[36m2024-05-16 18:00:24,270^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Printing config tree with Rich! <cfg.extras.print_config=True>^[[0m
[^[[36m2024-05-16 18:00:24,271^[[0m][^[[34msrc.utils.rich_utils^[[0m][^[[33mWARNING^[[0m] - [rank: 0] Field 'logger' not found in config. Skipping 'logger' config printing...^[[0m
CONFIG
├── data
│   └── _target_: src.data.perturb_datamodule.PertDataModule
│       data_dir: /data/home/bty174/scBench/data/splits/perturb
│       data_name: repogle_rpe1
"output.log" 212L, 15671C                                                                                                                                                                                        1,1           Top
Loading python/3.10.7
  Loading requirement: openssl/1.1.1s

Loading cudnn/8.4.1-cuda11.6
  Loading requirement: cuda/11.6.2
[^[[36m2024-05-16 18:00:24,264^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Enforcing tags! <cfg.extras.enforce_tags=True>^[[0m
[^[[36m2024-05-16 18:00:24,270^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Printing config tree with Rich! <cfg.extras.print_config=True>^[[0m
[^[[36m2024-05-16 18:00:24,271^[[0m][^[[34msrc.utils.rich_utils^[[0m][^[[33mWARNING^[[0m] - [rank: 0] Field 'logger' not found in config. Skipping 'logger' config printing...^[[0m
CONFIG
├── data
│   └── _target_: src.data.perturb_datamodule.PertDataModule
│       data_dir: /data/home/bty174/scBench/data/splits/perturb
│       data_name: repogle_rpe1
│       batch_size: 32
│       spectra_parameters:
│         number_repeats: 3
                                                                                                                                                                                                                 1,1           Top
Loading python/3.10.7
  Loading requirement: openssl/1.1.1s

Loading cudnn/8.4.1-cuda11.6
  Loading requirement: cuda/11.6.2
[^[[36m2024-05-16 18:00:24,264^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Enforcing tags! <cfg.extras.enforce_tags=True>^[[0m
[^[[36m2024-05-16 18:00:24,270^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Printing config tree with Rich! <cfg.extras.print_config=True>^[[0m
[^[[36m2024-05-16 18:00:24,271^[[0m][^[[34msrc.utils.rich_utils^[[0m][^[[33mWARNING^[[0m] - [rank: 0] Field 'logger' not found in config. Skipping 'logger' config printing...^[[0m
CONFIG
├── data
│   └── _target_: src.data.perturb_datamodule.PertDataModule
│       data_dir: /data/home/bty174/scBench/data/splits/perturb
│       data_name: repogle_rpe1
│       batch_size: 32
│       spectra_parameters:
│         number_repeats: 3
│         random_seed:
│         - 42
│         - 44
│         - 46
│         sparsification_step: 0.1
│         force_reconstruct: true
│       split: '0.00_0'
│       num_workers: 0
│       pin_memory: false
│
├── model
│   └── _target_: src.models.gears_module.GEARSLitModule
│       net:
│         _target_: src.models.reproduction.gears.gears.GEARSNetwork
│         hidden_size: 64
│         num_go_gnn_layers: 1
│         num_gene_gnn_layers: 1
│         decoder_hidden_size: 16
│         num_similar_genes_go_graph: 20
│         num_similar_genes_co_express_graph: 20
│         coexpress_threshold: 0.4
│         uncertainty: false
│         uncertainty_reg: 1
│         direction_lambda: 0.1
│         G_go: null
│         G_go_weight: null
│         G_coexpress: null
│         G_coexpress_weight: null
│         no_perturb: false
│         pert_emb_lambda: 0.2
│         num_genes: 5045
│         num_perts: 9853
│       pertmodule:
│         _target_: src.data.perturb_datamodule.PertDataModule
│       optimizer:
│         _target_: torch.optim.Adam
│         _partial_: true
│         lr: 0.001
│         weight_decay: 0.0005
│       scheduler:
│         _target_: torch.optim.lr_scheduler.StepLR
│         _partial_: true
│         step_size: 1
│         gamma: 0.5
│       model_name: gears
│       compile: false
│
├── callbacks
│   └── model_checkpoint:
│         _target_: lightning.pytorch.callbacks.ModelCheckpoint
│         dirpath: /data/home/bty174/scBench/logs/train/runs/2024-05-16_18-00-23
│         filename: best_model_at_epoch_{epoch:03d}
│         monitor: null
│         verbose: false
│         save_last: true
│         save_top_k: 1
│         mode: max
│         auto_insert_metric_name: false
│         save_weights_only: false
│         every_n_train_steps: null
│         train_time_interval: null
│         every_n_epochs: null
│         save_on_train_epoch_end: null
│       model_summary:
│         _target_: lightning.pytorch.callbacks.RichModelSummary
│         max_depth: -1
│
├── trainer
│   └── _target_: lightning.pytorch.trainer.Trainer
│       default_root_dir: /data/home/bty174/scBench/logs/train/runs/2024-05-16_1
│       min_epochs: 1
│       max_epochs: 20
│       accelerator: cpu
│       devices: 1
│       num_sanity_val_steps: 0
│       check_val_every_n_epoch: 1
│       deterministic: false
│
├── paths
│   └── root_dir: /data/home/bty174/scBench
│       data_dir: /data/home/bty174/scBench/data/splits/perturb
│       log_dir: /data/home/bty174/scBench/logs/
│       output_dir: /data/home/bty174/scBench/logs/train/runs/2024-05-16_18-00-2
│       work_dir: /data/home/bty174/scBench
│
├── extras
│   └── ignore_warnings: false
│       enforce_tags: true
│       print_config: true
│
├── task_name
│   └── train
├── tags
│   └── ['dev']
├── train
│   └── True
├── test
│   └── True
├── ckpt_path
│   └── None
└── seed
    └── None
[^[[36m2024-05-16 18:00:24,402^[[0m][^[[34m__main__^[[0m][^[[32mINFO^[[0m] - [rank: 0] Instantiating datamodule <src.data.perturb_datamodule.PertDataModule>^[[0m
[^[[36m2024-05-16 18:00:32,304^[[0m][^[[34mnumexpr.utils^[[0m][^[[32mINFO^[[0m] - Note: NumExpr detected 48 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.^[[0m
[^[[36m2024-05-16 18:01:12,350^[[0m][^[[34msrc.utils.utils^[[0m][^[[31mERROR^[[0m] - [rank: 0] ^[[0m
Traceback (most recent call last):
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/utils.py", line 644, in _locate
    obj = getattr(obj, part)
AttributeError: module 'src.data' has no attribute 'perturb_datamodule'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/utils.py", line 650, in _locate
    obj = import_module(mod)
  File "/share/apps/centos7/python/gcc/12.1.0/3.10.7/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/data/home/bty174/scBench/src/data/perturb_datamodule.py", line 4, in <module>
    from pertpy import data as scpert_data
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pertpy/__init__.py", line 18, in <module>
    from . import plot as pl
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pertpy/plot/__init__.py", line 2, in <module>
    from pertpy.plot._coda import CodaPlot as coda
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pertpy/plot/_coda.py", line 13, in <module>
    from pertpy.tools._coda._base_coda import CompositionalModel2
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pertpy/tools/__init__.py", line 5, in <module>
    from pertpy.tools._dialogue import Dialogue
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pertpy/tools/_dialogue.py", line 25, in <module>
    from sparsecca import lp_pmd, multicca_permute, multicca_pmd
  File "/data/home/bty174/.local/lib/python3.10/site-packages/sparsecca/__init__.py", line 5, in <module>
    from ._multicca_lp import lp_pmd
  File "/data/home/bty174/.local/lib/python3.10/site-packages/sparsecca/_multicca_lp.py", line 4, in <module>
    import pyomo.environ as pyo
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/environ/__init__.py", line 86, in <module>
    _import_packages()
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/environ/__init__.py", line 66, in _import_packages
    _do_import(pname)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/environ/__init__.py", line 18, in _do_import
    importlib.import_module(pkg_name)
  File "/share/apps/centos7/python/gcc/12.1.0/3.10.7/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/core/__init__.py", line 12, in <module>
    from pyomo.core.expr.numvalue import (
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/core/expr/__init__.py", line 203, in <module>
    from .calculus.derivatives import differentiate
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/core/expr/calculus/derivatives.py", line 13, in <module>
    from .diff_with_sympy import differentiate as sympy_diff
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/core/expr/calculus/diff_with_sympy.py", line 12, in <module>
    from pyomo.core.expr.sympy_tools import (
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py", line 113, in <module>
    sympy, sympy_available = attempt_import('sympy', callback=_configure_sympy)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/common/dependencies.py", line 738, in attempt_import
    return _perform_import(
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/common/dependencies.py", line 768, in _perform_import
    callback(module, True)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/pyomo/core/expr/sympy_tools.py", line 38, in _configure_sympy
    sympy.Mul: _prod,
NameError: name '_prod' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 134, in _resolve_target
    target = _locate(target)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/utils.py", line 658, in _locate
    raise ImportError(
ImportError: Error loading 'src.data.perturb_datamodule.PertDataModule':
NameError("name '_prod' is not defined")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/home/bty174/scBench/src/utils/utils.py", line 77, in wrap
    metric_dict, object_dict = task_func(cfg=cfg)
  File "/data/home/bty174/scBench/src/train.py", line 61, in train
    datamodule: LightningDataModule = hydra.utils.instantiate(cfg.data)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 226, in instantiate
    return instantiate_node(
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 333, in instantiate_node
    _target_ = _resolve_target(node.get(_Keys.TARGET), full_key)
  File "/data/home/bty174/.local/lib/python3.10/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 139, in _resolve_target
    raise InstantiationException(msg) from e
hydra.errors.InstantiationException: Error locating target 'src.data.perturb_datamodule.PertDataModule', set env var HYDRA_FULL_ERROR=1 to see chained exception.
full_key: data
[^[[36m2024-05-16 18:01:12,695^[[0m][^[[34msrc.utils.utils^[[0m][^[[32mINFO^[[0m] - [rank: 0] Output dir: /data/home/bty174/scBench/logs/train/runs/2024-05-16_18-00-23^[[0m
Error executing job with overrides: []
Error locating target 'src.data.perturb_datamodule.PertDataModule', set env var HYDRA_FULL_ERROR=1 to see chained exception.
full_key: data

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
                                                                                                                                                                                                                 212,1         Bot
```

Resolving patch:
diff --git a/pyomo/contrib/community_detection/detection.py b/pyomo/contrib/community_detection/detection.py
--- a/pyomo/contrib/community_detection/detection.py
+++ b/pyomo/contrib/community_detection/detection.py
@@ -580,7 +580,7 @@ def visualize_model_graph(
                 pos = nx.spring_layout(model_graph)
 
         # Define color_map
-        color_map = plt.cm.get_cmap('viridis', len(numbered_community_map))
+        color_map = plt.get_cmap('viridis', len(numbered_community_map))
 
         # Create the figure and draw the graph
         fig = plt.figure()
diff --git a/pyomo/core/expr/sympy_tools.py b/pyomo/core/expr/sympy_tools.py
--- a/pyomo/core/expr/sympy_tools.py
+++ b/pyomo/core/expr/sympy_tools.py
@@ -9,13 +9,13 @@
 #  This software is distributed under the 3-clause BSD License.
 #  ___________________________________________________________________________
 import operator
-import sys
+from math import prod as _prod
 
+import pyomo.core.expr as EXPR
 from pyomo.common import DeveloperError
 from pyomo.common.collections import ComponentMap
 from pyomo.common.dependencies import attempt_import
 from pyomo.common.errors import NondifferentiableError
-import pyomo.core.expr as EXPR
 from pyomo.core.expr.numvalue import value, native_types
 
 #
@@ -28,6 +28,25 @@
 _functionMap = {}
 
 
+def _nondifferentiable(x):
+    if type(x[1]) is tuple:
+        # sympy >= 1.3 returns tuples (var, order)
+        wrt = x[1][0]
+    else:
+        # early versions of sympy returned the bare var
+        wrt = x[1]
+    raise NondifferentiableError(
+        "The sub-expression '%s' is not differentiable with respect to %s" % (x[0], wrt)
+    )
+
+
+def _external_fcn(*x):
+    raise TypeError(
+        "Expressions containing external functions are not convertible to "
+        f"sympy expressions (found 'f{x}')"
+    )
+
+
 def _configure_sympy(sympy, available):
     if not available:
         return
@@ -113,37 +132,6 @@ def _configure_sympy(sympy, available):
 sympy, sympy_available = attempt_import('sympy', callback=_configure_sympy)
 
 
-if sys.version_info[:2] < (3, 8):
-
-    def _prod(args):
-        ans = 1
-        for arg in args:
-            ans *= arg
-        return ans
-
-else:
-    from math import prod as _prod
-
-
-def _nondifferentiable(x):
-    if type(x[1]) is tuple:
-        # sympy >= 1.3 returns tuples (var, order)
-        wrt = x[1][0]
-    else:
-        # early versions of sympy returned the bare var
-        wrt = x[1]
-    raise NondifferentiableError(
-        "The sub-expression '%s' is not differentiable with respect to %s" % (x[0], wrt)
-    )
-
-
-def _external_fcn(*x):
-    raise TypeError(
-        "Expressions containing external functions are not convertible to "
-        f"sympy expressions (found 'f{x}')"
-    )
-
-
 class PyomoSympyBimap(object):
     def __init__(self):
         self.pyomo2sympy = ComponentMap()
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -264,7 +264,9 @@ def __ne__(self, other):
             'ipython',  # contrib.viewer
             # Note: matplotlib 3.6.1 has bug #24127, which breaks
             # seaborn's histplot (triggering parmest failures)
-            'matplotlib!=3.6.1',
+            # Note: minimum version from community_detection use of
+            # matplotlib.pyplot.get_cmap()
+            'matplotlib>=3.6.0,!=3.6.1',
             # network, incidence_analysis, community_detection
             # Note: networkx 3.2 is Python>-3.9, but there is a broken
             # 3.2 package on conda-forge that will get implicitly


Test patch: