Install & Compatibility
Where this runs
tested against v6.10.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.803s · 58.2MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 4.7s · import 0.761s · 110MB
74MB installed
● package 74MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pyomo.environ
✓ import pyomo.environ as pyo
✗ from pyomo.environ import *
While 'from pyomo.environ import *' is often used in examples, 'import pyomo.environ as pyo' is generally preferred for clarity and to avoid polluting the global namespace, especially in larger applications.
ConcreteModel
✓ model = pyo.ConcreteModel()
Var
✓ model.x = pyo.Var(bounds=(0, 10))
Constraint
✓ model.con = pyo.Constraint(expr=...)
Objective
✓ model.obj = pyo.Objective(expr=..., sense=pyo.maximize)
SolverFactory
✓ solver = pyo.SolverFactory('glpk')
This quickstart defines and solves a simple linear programming problem using Pyomo. It demonstrates the creation of a concrete model, defining variables with bounds, an objective function, and constraints. To run this, you need a compatible solver (e.g., GLPK) installed on your system and accessible via Pyomo's SolverFactory.
import pyomo.environ as pyo
# Create a concrete model
model = pyo.ConcreteModel()
# Define variables
model.x = pyo.Var(bounds=(0, 10), within=pyo.Reals)
model.y = pyo.Var(bounds=(0, 10), within=pyo.Reals)
# Define objective function: Maximize x + y
model.obj = pyo.Objective(expr=model.x + model.y, sense=pyo.maximize)
# Define constraints
model.con1 = pyo.Constraint(expr=2*model.x + model.y <= 15)
model.con2 = pyo.Constraint(expr=model.x + 3*model.y <= 20)
# Solve the model (requires a solver, 'glpk' is a common choice)
# Ensure 'glpk' or another solver is installed and accessible in your system PATH.
# For example, on Ubuntu: 'sudo apt-get install glpk-utils'
# On macOS: 'brew install glpk'
# On Windows: download GLPK binaries and add to PATH.
try:
solver = pyo.SolverFactory('glpk')
results = solver.solve(model, tee=False) # tee=True shows solver output
# Check solver status and print results
if (results.solver.status == pyo.SolverStatus.ok) and \
(results.solver.termination_condition == pyo.TerminationCondition.optimal):
print(f"Optimization successful!")
print(f"Objective value: {pyo.value(model.obj)}")
print(f"x = {pyo.value(model.x)}")
print(f"y = {pyo.value(model.y)}")
else:
print(f"Solver did not find an optimal solution. Status: {results.solver.status}, Termination: {results.solver.termination_condition}")
except Exception as e:
print(f"Error solving model: {e}")
print("Please ensure a solver like 'glpk' is installed and configured for Pyomo.")
pyomo --version
Debug
Known issues
breakingPyomo regularly drops support for older Python versions. Pyomo 6.10.0 removes support for Python 3.9. Pyomo 6.9.x removed support for Python 3.8.fixUpgrade your Python environment to a version officially supported by your Pyomo release. For Pyomo 6.10.0, Python >=3.10 is required.
affects: 6.10.0+ (Python 3.9), 6.9.0+ (Python 3.8)
gotchaPyomo itself does NOT include optimization solvers. You must install external solver executables (e.g., GLPK, CBC, Ipopt, Gurobi, CPLEX) on your system and ensure they are in your system's PATH, or configure Pyomo with their specific location.fixConsult the Pyomo documentation for integrating specific solvers. For example, to use GLPK, install 'glpk-utils' (Linux), 'glpk' (macOS via Homebrew), or download Windows binaries and add them to your PATH.
affects: All versions
breakingInternal data storage for Constraint objects changed significantly in Pyomo 6.8.0. Code that directly accessed or manipulated internal Constraint attributes might break.fixReview and update any code that deeply interacts with Pyomo's internal Constraint object structure. Rely on the public API where possible.
affects: 6.8.0+
gotchaWhile `import pyomo.environ as pyo` is convenient, for very large or performance-critical models, using direct imports from specific submodules (e.g., `from pyomo.core import ConcreteModel, Var`) can improve startup performance by avoiding the overhead of `environ`'s extensive imports.fixConsider explicit, granular imports for production-grade or performance-sensitive applications, especially when `pyomo.environ` contributes to slow model initialization.
affects: All versions
deprecatedThe hard dependency on `ply` was removed in Pyomo 6.10.0. While not strictly a breaking change for most users, if you were implicitly relying on `ply` being installed alongside Pyomo, you might need to add it as an explicit dependency for your project.fixIf your project directly or indirectly relies on `ply`, ensure it is explicitly listed in your project's dependencies.
affects: 6.10.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyomo'
The Pyomo library is not installed in the active Python environment.
fixInstall Pyomo using pip or conda in your environment.
`pip install pyomo`
or
`conda install -c conda-forge pyomo`
NameError: name 'ConcreteModel' is not defined
Core Pyomo components like `ConcreteModel`, `Var`, `Objective`, or `Constraint` have not been imported from `pyomo.environ`.
fixImport the necessary components from `pyomo.environ` at the beginning of your script.
`from pyomo.environ import *`
or
`from pyomo.environ import ConcreteModel, Var, Objective, Constraint`
ApplicationError: No executable found for solver 'glpk'
The specified solver executable (e.g., `glpsol` for GLPK) is not installed on your system, or its path is not included in your system's PATH environment variable, preventing Pyomo from finding it.
fixInstall the desired solver executable (e.g., GLPK, CBC) and ensure its location is in your system's PATH, or provide the full path to the solver executable when initializing SolverFactory.
`conda install -c conda-forge glpk` (for GLPK)
or
`SolverFactory('glpk', executable='/path/to/glpsol')` AttributeError: 'NoneType' object has no attribute 'value'
This typically occurs when attempting to access the `.value` attribute of a Pyomo variable before a successful solve, or when the optimization problem is infeasible or unbounded, causing the variable's value to remain `None`.
fixEnsure the model is successfully solved before attempting to access variable values, and check the solver's termination condition to confirm a valid solution was found.
```python
results = SolverFactory('glpk').solve(model)
if (results.solver.status == 'ok' and
results.solver.termination_condition == 'optimal'):
# Access values safely
print(model.x.value)
else:
print("Solver did not find an optimal solution.")
``` Upgrade
Version history
6.10.1latest on PyPI · released Jun 4, 2026
Audit
Dependencies
No dependency data recorded yet.