You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# example.py
from pyomo.environ import *
# Create a model
model = ConcreteModel()
# Define variables (x, y >= 0)
model.x = Var(within=NonNegativeReals)
model.y = Var(within=NonNegativeReals)
# Define objective function (Maximize Z = 3x + 5y)
model.objective = Objective(expr=3 * model.x + 5 * model.y, sense=maximize)
# Define constraints
model.constraint1 = Constraint(expr=2 * model.x + 3 * model.y <= 12)
model.constraint2 = Constraint(expr=model.x + model.y <= 5)
# Solve the model using CBC
solver = SolverFactory('cbc')
result = solver.solve(model)
# Display results
model.display()
Error Message
$ ApplicationError: No executable found for solver 'cbc'
Information on your system
Pyomo version: Pyomo 6.8.2
Python version: 3.12.7
Operating system: macos sequoia, version 15.2
How Pyomo was installed (PyPI, conda, source): poetry
Solver (if applicable): cbc
Additional information
I also get False in here:
frompyomo.environimportSolverFactoryprint("Available solvers:")
print(SolverFactory('cbc').available(exception_flag=False)) # Should return Trueprint(SolverFactory('ipopt').available(exception_flag=False)) # Should return True
but I run which cbc in terminal and it returns /usr/local/bin/cbc. I have also got this error during a .solve:
-> [2274](https://file+.vscode-resource.vscode-cdn.net/Users/davidmasip/Documents/Workspace/pricing-data/dynamic_pricing/notebooks/~/Documents/Workspace/pricing-data/dynamic_pricing/.venv/lib/python3.12/site-packages/pyomo/contrib/mindtpy/algorithm_base_class.py:2274) raiseValueError(self.config.mip_solver+' is not available.')
[2275](https://file+.vscode-resource.vscode-cdn.net/Users/davidmasip/Documents/Workspace/pricing-data/dynamic_pricing/notebooks/~/Documents/Workspace/pricing-data/dynamic_pricing/.venv/lib/python3.12/site-packages/pyomo/contrib/mindtpy/algorithm_base_class.py:2275) ifnotself.mip_opt.license_is_valid():
[2276](https://file+.vscode-resource.vscode-cdn.net/Users/davidmasip/Documents/Workspace/pricing-data/dynamic_pricing/notebooks/~/Documents/Workspace/pricing-data/dynamic_pricing/.venv/lib/python3.12/site-packages/pyomo/contrib/mindtpy/algorithm_base_class.py:2276) raiseValueError(self.config.mip_solver+' is not licensed.')
ValueError: cbcisnotavailable.
The text was updated successfully, but these errors were encountered:
This looks like you are not running from a command line and instead are running from within vscode. Most likely, your vscode environment (particularly the PATH) doesn't match the environment you are using in a terminal. Fixing that should resolve your problem.
Alternatively, you can manually set the path to CBC with:
Summary
Steps to reproduce the issue
Error Message
$ ApplicationError: No executable found for solver 'cbc'
Information on your system
Pyomo version: Pyomo 6.8.2
Python version: 3.12.7
Operating system: macos sequoia, version 15.2
How Pyomo was installed (PyPI, conda, source): poetry
Solver (if applicable): cbc
Additional information
I also get False in here:
but I run
which cbc
in terminal and it returns /usr/local/bin/cbc. I have also got this error during a .solve:The text was updated successfully, but these errors were encountered: