You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 13:43:16