Pyomo导入NonNegativeReals、Reals报错,求解决方案
Pyomo导入NonNegativeReals、Reals时出现引用找不到错误
我正在使用Python的Pyomo库处理优化问题,Pyomo已成功安装,但导入必要模块时出现如下错误:
导入代码
from pyomo.environ import ( ConcreteModel, Set, Param, Var, NonNegativeReals, Reals, Objective, Constraint, value, SolverFactory, Expression )
错误信息
Cannot find reference 'NonNegativeReals' in '__init__.py' Cannot find reference 'Reals' in '__init__.py'
已尝试的解决方法
- 重装Pyomo:执行
pip uninstall pyomo后重新安装,也尝试了pip install --upgrade pyomo,问题仍存在; - 手动安装特定依赖:尝试安装Pyomo子模块,未解决问题;
- 检查Python版本与环境:最初使用Python 3.9.12在PyCharm Pro中运行,当前系统信息为Python 3.12、Pyomo 6.8.2、Windows系统。
求可行的解决建议!
内容的提问来源于stack exchange,提问作者user14885037
相关产品推荐
相关产品推荐

