Search code examples
pythonpippyomo

No module named 'pyomo.environ'


I'm trying to use Pyomo for solving optimization problems. I'm trying to run the following piece of code

import pyomo.environ as pyo

model = pyo.AbstractModel()


model.n = pyo.Param(within=pyo.NonNegativeIntegers)

model.I = pyo.RangeSet(1, model.m)

but I get the following error

ModuleNotFoundError: No module named 'pyomo.environ'; 'pyomo' is not a package

im not sure whats causing this as i have followed the installation instructions on the pyomo documentation website. I've installed pyomo using pip

pip install pyomo

and i also tried using the conda environment by installing pyomo there and running the script from conda but got same error. Im not sure what pyomo.environ is but i tried running the following pip call pip install pyomo.environ but got an error that no such package exists.

anyone know why im missing this module? isn't pyomo.environ supposed to be part of the pyomo package, if not how am i supposed to install it?


Solution

  • a comment suggested that the problem was a naming issue. the file name was the same name as the package, renaming the file fixed the problem