This file is a slight modification of the basic "WYNDOR GLASS CO." example file which shows how to use indexed decision variables.
from pyomo.environ import *
from pyomo.opt import *
opt = solvers.SolverFactory("glpk")
model = ConcreteModel()
model.x = Var([1,2], within=NonNegativeReals)
model.c1 = Constraint(expr = model.x[1] <= 4)
model.c2 = Constraint(expr = 2*model.x[2] <= 12)
model.c3 = Constraint(expr = 3*model.x[1] + 2*model.x[2] <= 18)
model.z = Objective(expr = 3*model.x[1] + 5*model.x[2], sense=maximize)
results = opt.solve(model)
model.x.get_values()
model.z.expr()