Skip to content

ApplicationError: No executable found for solver 'cbc' #3477

Closed
@david26694

Description

@david26694

Summary

Steps to reproduce the issue

$ which cbc
$ python example.py
# 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:

from pyomo.environ import SolverFactory

print("Available solvers:")
print(SolverFactory('cbc').available(exception_flag=False))  # Should return True
print(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)     raise ValueError(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) if not self.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)     raise ValueError(self.config.mip_solver + ' is not licensed.')

ValueError: cbc is not available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions