Skip to content

solver.status_name() raises TypeError: 'ortools.sat.python.cp_model_helper.CpSolverStatus' object is not callable #4985

Closed

Description

@gacheiro

What version of OR-Tools and what language are you using?
Version: v9.15.6755
Language: Python

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
solver: CP-SAT

What operating system (Linux, Windows, ...) and version?
OS: Linux

What did you do?
After solving a model with the CP-SAT solver, the callable solver.status_name() raises:

TypeError: 'ortools.sat.python.cp_model_helper.CpSolverStatus' object is not callable

Steps to reproduce the behavior:

model = cp_model.CpModel()
model.minimize(1)
solver = cp_model.CpSolver()
status = solver.Solve(model)
print(solver.status_name())

What did you expect to see
Should print "OPTIMAL"

What did you see instead?
TypeError: 'ortools.sat.python.cp_model_helper.CpSolverStatus' object is not callable

It works for version 9.14.6206

Activity

  1. added this to the v9.16 milestone on Jan 15, 2026
  2. Mizux commented on Jan 15, 2026

    @Mizux
    Collaborator

    Confirmed using any sat sample: ortools/sat/samples/binpacking_problem_sat.py and changing it.

    workaround use the "old" version:

    status = solver.Solve(model)
    print(solver.status_name(satus))

    devNote:

    diff --git a/ortools/sat/samples/binpacking_problem_sat.py b/ortools/sat/samples/binpacking_problem_sat.py
    index 29bbe84da1..cabf3296a0 100644
    --- a/ortools/sat/samples/binpacking_problem_sat.py
    +++ b/ortools/sat/samples/binpacking_problem_sat.py
    @@ -69,7 +69,8 @@ def binpacking_problem_sat():
         # Solves and prints out the solution.
         solver = cp_model.CpSolver()
         status = solver.solve(model)
    -    print(f"solve status: {solver.status_name(status)}")
    +    print(f"solve status old: {solver.status_name(status)}") # pass
    +    print(f"solve status new: {solver.status_name()}") # fail
         if status == cp_model.OPTIMAL:
             print(f"Optimal objective value: {solver.objective_value}")
         print("Statistics")
  3. Mizux commented on Jan 15, 2026

    @Mizux
    Collaborator

    same issue on main:

    trace:

    ./build/python/venv/bin/python ortools/sat/samples/binpacking_problem_sat_hacked.py
    Traceback (most recent call last):
      File "ortools/sat/samples/binpacking_problem_sat.py", line 82, in <module>
        binpacking_problem_sat()
        ~~~~~~~~~~~~~~~~~~~~~~^^
      File "ortools/sat/samples/binpacking_problem_sat.py", line 72, in binpacking_problem_sat
        print(f"solve status 1: {solver.status_name()}")
                                 ~~~~~~~~~~~~~~~~~~^^
      File "build/python/venv/lib/python3.13/site-packages/ortools/sat/python/cp_model.py", line 1955, in status_name
        status = self._checked_response.status()
    TypeError: 'ortools.sat.python.cp_model_helper.CpSolverStatus' object is not callable
    
  4. Mizux commented on Jan 15, 2026

    @Mizux
    Collaborator

    To Fix, you can modify locally your site-packages/ortools/sat/python/cp_model.py
    note: you can use python3 -m pip show ortools to find location

    diff -u ortools/sat/python/cp_model.py build/python/venv/lib/python3.13/site-packages/ortools/sat/python/cp_model.py
    --- ortools/sat/python/cp_model.py	2026-01-05 12:48:19.952391675 +0100
    +++ build/python/venv/lib/python3.13/site-packages/ortools/sat/python/cp_model.py	2026-01-15 11:18:00.654856848 +0100
    @@ -1952,7 +1952,7 @@
         def status_name(self, status: Optional[Any] = None) -> str:
             """Returns the name of the status returned by solve()."""
             if status is None:
    -            status = self._checked_response.status()
    +            status = self._checked_response.status
             return status.name
     
         def solution_info(self) -> str:
  5. added and removed on Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions